Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] purchase_requisition_proposal module #256

Open
wants to merge 6 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion product_pricelist_per_attribute_value/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/akretion/ak-odoo-incubator",
"license": "AGPL-3",
"depends": ["product"],
"depends": [
"product",
"web_domain_field",
],
"data": [
"views/product_pricelist.xml",
],
Expand Down
55 changes: 40 additions & 15 deletions product_pricelist_per_attribute_value/models/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import itertools
import json

from odoo import api, fields, models

Expand Down Expand Up @@ -34,28 +35,52 @@ class PricelistItem(models.Model):
string="Attribute Values",
help="Specify values if this rule only applies to this product "
"attribute values. Keep empty otherwise.",
compute="_compute_product_attribute_value_ids",
readonly=False,
store=True,
)
product_attribute_value_domain = fields.Char(
compute="_compute_product_attribute_value_domain",
)

@api.depends("product_attribute_value_ids")
def _compute_attribute_value_restricted(self):
for record in self:
record.attribute_value_restricted = bool(record.product_attribute_value_ids)

@api.onchange("applied_on", "product_tmpl_id", "categ_id")
def _onchange_attribute_value_domain(self):
self.ensure_one()
domain = []
self.product_attribute_value_ids = None
if self.applied_on == "1_product" and self.product_tmpl_id:
values = self.product_tmpl_id.attribute_line_ids.value_ids
domain = [("id", "in", values.ids)]
elif self.applied_on == "2_product_category" and self.categ_id:
product_templates = self.env["product.template"].search(
[("categ_id", "child_of", self.categ_id.id)]
)
values = product_templates.attribute_line_ids.value_ids
domain = [("id", "in", values.ids)]
return {"domain": {"product_attribute_value_ids": domain}}
@api.depends("applied_on", "product_tmpl_id", "categ_id")
def _compute_product_attribute_value_domain(self):
for record in self:
if record.applied_on == "1_product" and record.product_tmpl_id:
domain = [
(
"id",
"in",
record.product_tmpl_id.attribute_line_ids.value_ids.ids,
)
]
elif record.applied_on == "2_product_category" and record.categ_id:
product_templates = record.env["product.template"].search(
[("categ_id", "child_of", record.categ_id.id)]
)
domain = [
("id", "in", product_templates.attribute_line_ids.value_ids.ids)
]
else:
domain = []
record.product_attribute_value_domain = json.dumps(domain)

@api.depends("applied_on", "product_tmpl_id", "categ_id")
def _compute_product_attribute_value_ids(self):
for record in self:
if record.applied_on == "0_product_variant":
record.product_attribute_value_ids = None
elif record.product_attribute_value_ids:
record.product_attribute_value_ids = (
record.product_attribute_value_ids.filtered_domain(
json.loads(record.product_attribute_value_domain)
)
)

@api.depends("product_attribute_value_ids.name")
def _get_pricelist_item_name_price(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
name="pricelist_rule_target_attribute_value"
attrs="{'invisible':[('applied_on', '=', '0_product_variant')]}"
>
<field name="product_attribute_value_domain" invisible="1" />
<field
name="product_attribute_value_ids"
domain="product_attribute_value_domain"
widget="many2many_tags"
options="{'no_create':1}"
/>
Expand Down
2 changes: 2 additions & 0 deletions purchase_requisition_proposal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizard
32 changes: 32 additions & 0 deletions purchase_requisition_proposal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2023 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Purchase Requirement Proposal",
"summary": "SUMMARY",
"version": "14.0.1.0.0",
"category": "CAT",
"website": "https://github.com/akretion/ak-odoo-incubator",
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["Kev-Roche"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"purchase_requisition",
"purchase_sale_inter_company",
"mail",
],
"data": [
"data/data.xml",
"views/purchase_order.xml",
"views/sale_order.xml",
"views/purchase_requisition.xml",
"views/purchase_requisition_type.xml",
"wizard/wizard_requisition_proposal.xml",
"views/ir_config.xml",
"security/ir.model.access.csv",
"security/purchase_requisition_security.xml",
],
}
188 changes: 188 additions & 0 deletions purchase_requisition_proposal/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright (C) 2023 Akretion (<http://www.akretion.com>).
@author Kévin Roche <[email protected]>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="call_for_proposals_type" model="purchase.requisition.type">
<field name="name">Intercompany Call for Proposals</field>
<field name="sequence">-1</field>
<field name="line_copy">copy</field>
<field name="quantity_copy">none</field>
<field name="exclusive">proposals</field>
</record>
<record id="seq_purchase_requisition_proposal" model="ir.sequence">
<field name="name">Purchase Requisition Proposal</field>
<field name="code">purchase.requisition.proposal</field>
<field name="prefix">PROP</field>
<field name="padding">5</field>
<field name="company_id" eval="False" />
</record>
<record id="seq_purchase_call" model="ir.sequence">
<field name="name">Purchase Requisition Call </field>
<field name="code">purchase.requisition.purchase.call</field>
<field name="prefix">CALL</field>
<field name="padding">5</field>
<field name="company_id" eval="False" />
</record>
<record id="mail_template_requisition_proposal" model="mail.template">
<field name="name">Requistion Call: Send by email</field>
<field name="model_id" ref="purchase_requisition.model_purchase_requisition" />
<field
name="subject"
>${object.company_id.name} Call for Proposals (Ref ${object.name or 'n/a' })</field>
<field name="use_default_to" eval="True" />
<field name="body_html" type="xml">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear collaborator,<br /><br />
<strong
>${object.company_id.name}</strong> have a new Call for Proposals: <strong
>${object.name}</strong>.<br />
The Agreement Deadline is <strong
>${format_date(object.date_end)}</strong>.
<br /><br />
Do not hesitate to contact us if you have any questions.
<br /><br />
<div style="margin:0px;padding: 0px;">
<table
style="color:#454748;font-size: 12px; border-collapse: collapse;"
width="70%"
>
<tbody>
<tr style="border-bottom:2px solid #dee2e6;">
<td width="25%"><strong
>Products</strong></td>
<td width="15%" align="center"><strong
>Quantity</strong></td>
<td width="10%" align="center"><strong
>Price</strong></td>
<td width="15%" align="right"><strong
>Schedule Date</strong></td>
</tr>
</tbody>
</table>
<table
style="color:#454748;font-size: 12px; border-collapse: collapse;"
width="70%"
>
<tbody>
% for line in object.line_ids:
<tr>
<td
width="25%"
>${line.product_id.display_name}</td>
<td width="15%" align="center"><strong
>${line.product_qty}</strong> ${line.product_uom_id.name}</td>
<td width="10%" align="center"><strong>
${line.price_unit}</strong>
</td>
<td width="15%" align="right"><strong
>${format_date(line.schedule_date)} </strong></td>
</tr>
% endfor
</tbody>
</table>
<br /><br />
Best regards,
% if user.signature:
<br />
${user.signature | safe}
% endif
</div>
</p>
</div>
</field>
<field name="report_name">${(object.name or '').replace('/','-')}</field>
<field name="lang">${object.company_id.lang}</field>
<field name="auto_delete" eval="True" />
<field name="email_cc">${object.user_id.email}</field>
</record>

<record id="mail_template_result_proposal" model="mail.template">
<field name="name">Requistion Call: Send Result by email</field>
<field name="model_id" ref="purchase_requisition.model_purchase_requisition" />
<field
name="subject"
>${object.company_id.name} Closed Call for Proposals (Ref ${object.name or 'n/a' })</field>
<field name="use_default_to" eval="True" />
<field name="body_html" type="xml">
<div style="margin: 0px; padding: 0px;">
<p style="margin: 0px; padding: 0px; font-size: 13px;">
Dear collaborator,<br /><br />
The Call <strong>${object.name}</strong> from <strong
>${object.company_id.name}</strong> is now closed.<br />
Please find the selected proposals below:
<br /><br />
<div style="margin:0px;padding: 0px;">
% for line in object.line_ids:
<h4>${line.product_id.display_name}</h4>
<ul>
<li>Schedule Date: ${format_date(line.schedule_date)}</li>
<li
>Quantity: ${line.product_qty} ${line.product_uom_id.name}</li>
<li>Unit Price: ${line.price_unit}</li>
% if not line.qty_planned:
<li><b>Not Planned</b></li>
% endif
</ul>

% for prop in line.proposal_line_ids:
% if prop.qty_planned:
<table
style="color:#454748;font-size: 12px; border-collapse: collapse;"
width="70%"
>
<tbody>
<tr style="border-bottom:2px solid #dee2e6;">
<td width="10%" align="left"><strong
>Proposal</strong></td>
<td width="25%" align="center"><strong
>Company</strong></td>
<td width="15%" align="center"><strong
>Planned Quantity</strong></td>
<td width="15%" align="right"><strong
>Planned Date</strong></td>
</tr>
</tbody>
</table>
<table width="70%">
<tbody>
<tr>
<td width="10%" align="left">${prop.name}</td>
<td
width="25%"
align="center"
>${prop.partner_id.name} </td>
<td
width="15%"
align="center"
>${prop.qty_planned} ${prop.product_uom_id.name}</td>
<td width="15%" align="right"><strong>
${prop.date_planned}
</strong></td>
</tr>
</tbody>
</table>
<br />
% endif
% endfor
% endfor
<br /><br />
Thank you for your participation.
<br />
Best regards,
% if user.signature:
<br />
${user.signature | safe}
% endif
</div>
</p>
</div>
</field>
<field name="report_name">${(object.name or '').replace('/','-')}</field>
<field name="lang">${object.company_id.lang}</field>
<field name="auto_delete" eval="True" />
<field name="email_cc">${object.user_id.email}</field>
</record>

</odoo>
Loading
Loading