diff --git a/purchase_third_party/__manifest__.py b/purchase_third_party/__manifest__.py index d07b8b917..c44e6d5ab 100644 --- a/purchase_third_party/__manifest__.py +++ b/purchase_third_party/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Purchase Third Party", - "version": "14.0.1.0.0", + "version": "16.0.1.0.0", "author": "Eficent, CreuBlanca", "website": "https://github.com/tegin/cb-addons", "summary": "Creates inter company relations", diff --git a/purchase_third_party/data/mail_template_data.xml b/purchase_third_party/data/mail_template_data.xml index c98843011..e8887036c 100644 --- a/purchase_third_party/data/mail_template_data.xml +++ b/purchase_third_party/data/mail_template_data.xml @@ -1,41 +1,38 @@ - - - - - RFQ - Send by Email - ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} - ${object.partner_id.name} Order (Ref ${object.name or 'n/a' }) - ${object.third_party_partner_id.id},${object.partner_id.id} - - - - RFQ_${(object.name or '').replace('/','_')} - ${object.third_party_partner_id.lang} - + + + RFQ - Send by Email + ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} + ${object.partner_id.name} Order (Ref ${object.name or 'n/a' }) + ${object.third_party_partner_id.id},${object.partner_id.id} + + + + RFQ_${(object.name or '').replace('/','_')} + ${object.third_party_partner_id.lang} + Dear % if object.third_party_partner_id.is_company and object.third_party_partner_id.child_ids: - ${object.third_party_partner_id.child_ids[0].name} +${object.third_party_partner_id.child_ids[0].name} % else : - ${object.third_party_partner_id.name} +${object.third_party_partner_id.name} % endif ,

Here is, in attachment, a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} ${object.name} % if object.partner_ref: - with reference: ${object.partner_ref} +with reference: ${object.partner_ref} % endif % if object.origin: - (RFQ origin: ${object.origin}) +(RFQ origin: ${object.origin}) % endif amounting in ${format_amount(object.amount_total, object.currency_id)} from ${object.partner_id.name}. @@ -45,43 +42,43 @@ from ${object.partner_id.name}.

Best regards,

% if object.user_id and object.user_id.signature: - ${object.user_id.signature | safe} +${object.user_id.signature | safe} % endif

]]>
-
- - - Purchase Order - Send by Email - ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} - ${object.partner_id.name} Order (Ref ${object.name or 'n/a' }) - ${object.third_party_partner_id.id},${object.partner_id.id} - - - - PO_${(object.name or '').replace('/','_')} - ${object.third_party_partner_id.lang} - + + + Purchase Order - Send by Email + ${(object.create_uid.email and '"%s" <%s>' % (object.create_uid.name, object.create_uid.email) or '')|safe} + ${object.partner_id.name} Order (Ref ${object.name or 'n/a' }) + ${object.third_party_partner_id.id},${object.partner_id.id} + + + + PO_${(object.name or '').replace('/','_')} + ${object.third_party_partner_id.lang} + Dear ${object.third_party_partner_id.name} % if object.third_party_partner_id.parent_id: - (${object.third_party_partner_id.parent_id.name}) +(${object.third_party_partner_id.parent_id.name}) % endif ,

Please find in attachment a ${object.state in ('draft', 'sent') and 'request for quotation' or 'purchase order confirmation'} ${object.name} % if object.partner_ref: - with reference: ${object.partner_ref} +with reference: ${object.partner_ref} % endif % if object.origin: - (RFQ origin: ${object.origin}) +(RFQ origin: ${object.origin}) % endif amounting ${format_amount(object.amount_total, object.currency_id)} from ${object.partner_id.name}. @@ -90,83 +87,82 @@ from ${object.partner_id.name}.

You can reply to this email if you have any questions.

Thank you,

]]>
-
- - - Purchase Order Notification Email - ${object.subject} - - - - - % set partner = ctx.get('record').partner_id - - - - - - - - - - - - - - - - - - - -
- - - - -
- - ${object.record_name} - -
-
- - - - -
- ${object.body | safe} -
-
- - - - - -
- ${partner.name}
- ${partner.phone or ''} -
- % if partner.email: - ${partner.email}
- % endif - % if partner.website: - - ${partner.website} - - % endif -
-
- Powered by Odoo. -
- - - ]]>
-
-
+ + + + Purchase Order Notification Email + ${object.subject} + + + + + % set partner = ctx.get('record').partner_id + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + ${object.record_name} + +
+
+ + + + +
+ ${object.body | safe} +
+
+ + + + + +
+ ${partner.name}
+ ${partner.phone or ''} +
+ % if partner.email: + ${partner.email}
+ % endif + % if partner.website: + + ${partner.website} + + % endif +
+
+ Powered by Odoo. +
+ + + ]]>
+
diff --git a/purchase_third_party/models/product_supplierinfo.py b/purchase_third_party/models/product_supplierinfo.py index 97168ad00..51dbcf0fa 100644 --- a/purchase_third_party/models/product_supplierinfo.py +++ b/purchase_third_party/models/product_supplierinfo.py @@ -22,7 +22,7 @@ def _check_third_party_price(self): @api.constrains( "third_party_partner_id", - "name", + "partner_id", "product_id", "date_start", "date_end", @@ -81,7 +81,7 @@ def _check_third_party(self): [ ("id", "!=", rec.id), ("product_id", "=", rec.product_id.id), - ("name", "=", rec.name.id), + ("partner_id", "=", rec.partner_id.id), ( "third_party_partner_id", "!=", @@ -101,7 +101,7 @@ def _check_third_party(self): [ ("id", "!=", rec.id), ("product_tmpl_id", "=", rec.product_tmpl_id.id), - ("name", "=", rec.name.id), + ("partner_id", "=", rec.partner_id.id), ( "third_party_partner_id", "!=", diff --git a/purchase_third_party/models/purchase_order.py b/purchase_third_party/models/purchase_order.py index c519b2aac..5ab1044ba 100644 --- a/purchase_third_party/models/purchase_order.py +++ b/purchase_third_party/models/purchase_order.py @@ -51,17 +51,15 @@ def action_rfq_send(self): res = super().action_rfq_send() if self.env.context.get("third_party_send"): ctx = res.get("context") - ir_model_data = self.env["ir.model.data"] try: if self.env.context.get("send_rfq", False): - template_id = ir_model_data.get_object_reference( - "purchase_third_party", "email_template_edi_purchase" - )[1] + template_id = self.env.ref( + "purchase_third_party.email_template_edi_purchase" + ).id else: - template_id = ir_model_data.get_object_reference( - "purchase_third_party", - "email_template_edi_purchase_done", - )[1] + template_id = self.env.ref( + "purchase_third_party.email_template_edi_purchase_done" + ).id except ValueError: template_id = False ctx.update( @@ -119,8 +117,8 @@ def _compute_amount_third_party(self): ) @api.onchange("product_qty", "product_uom") - def _onchange_quantity(self): - res = super()._onchange_quantity() + def _compute_price_unit_and_date_planned_and_name(self): + res = super()._compute_price_unit_and_date_planned_and_name() if not self.product_id or not self.order_id.third_party_order: return res seller = self.product_id._select_seller( @@ -170,7 +168,7 @@ def _prepare_purchase_order_line_from_procurement( product_id, product_qty, product_uom, company_id, values, po ) procurement_uom_po_qty = res["product_qty"] - partner = values["supplier"].name + partner = values["supplier"].partner_id seller = product_id._select_seller( partner_id=partner, quantity=procurement_uom_po_qty, diff --git a/purchase_third_party/models/res_partner.py b/purchase_third_party/models/res_partner.py index 9f633ebdd..8786ba194 100644 --- a/purchase_third_party/models/res_partner.py +++ b/purchase_third_party/models/res_partner.py @@ -9,7 +9,7 @@ class ResPartner(models.Model): _inherit = "res.partner" supplier_info_ids = fields.One2many( - "product.supplierinfo", inverse_name="name", check_company=True + "product.supplierinfo", inverse_name="partner_id", check_company=True ) third_party_supplier_info_ids = fields.One2many( @@ -25,7 +25,7 @@ def action_view_product_supplierinfo(self): ) action["domain"] = [ "|", - ("name", "=", self.id), + ("partner_id", "=", self.id), ("third_party_partner_id", "=", self.id), ] return action diff --git a/purchase_third_party/report/external_layout.xml b/purchase_third_party/report/external_layout.xml index 501c01c2a..59f9ff425 100644 --- a/purchase_third_party/report/external_layout.xml +++ b/purchase_third_party/report/external_layout.xml @@ -10,7 +10,7 @@
diff --git a/purchase_third_party/report/purchase_order_templates.xml b/purchase_third_party/report/purchase_order_templates.xml index 423884bc6..d18dcd3fb 100644 --- a/purchase_third_party/report/purchase_order_templates.xml +++ b/purchase_third_party/report/purchase_order_templates.xml @@ -11,27 +11,56 @@ o.third_party_partner_id - - o.third_party_partner_id.vat - - - o.third_party_partner_id.vat - line.third_party_price_unit line.third_party_price_subtotal - - o.tp_amount_untaxed + + False - - o.tp_amount_tax - - - o.tp_amount_total + +
+
+ + + + + + + + + + + + + +
+ Subtotal + + +
Taxes + +
+ Total + + +
+
+
+ + + - purchase_third_party.report_purchaseorder_third_party + Third Party Purchase Order + purchase.order qweb-pdf (object.state in ('draft', 'sent') and 'Request for Quotation - %s' % (object.name) or 'Purchase Order - %s' % (object.name)) - purchase.order + name="report_name" + >purchase_third_party.report_purchaseorder_third_party purchase_third_party.report_purchaseorder_third_party - purchase_third_party.report_purchaseorder_third_party - + + (object.state in ('draft', 'sent') and 'Request for Quotation - %s' % (object.name) or + 'Purchase Order - %s' % (object.name)) + + report + diff --git a/purchase_third_party/report/purchase_quotation_templates.xml b/purchase_third_party/report/purchase_quotation_templates.xml index f286c880a..bc21363b3 100644 --- a/purchase_third_party/report/purchase_quotation_templates.xml +++ b/purchase_third_party/report/purchase_quotation_templates.xml @@ -11,12 +11,6 @@ o.third_party_partner_id - - o.third_party_partner_id.vat - - - o.third_party_partner_id.vat - - purchase_third_party.report_purchaseorder_third_party + Third Party Request for Quotation + purchase.order qweb-pdf 'Third Party Request for Quotation - %s' % (object.name) - purchase.order + name="report_name" + >purchase_third_party.report_purchasequotation_third_party purchase_third_party.report_purchaseorder_third_party + >purchase_third_party.report_purchasequotation_third_party purchase_third_party.report_purchaseorder_third_party - + name="print_report_name" + >'Request for Quotation - %s' % (object.name) + + report diff --git a/purchase_third_party/tests/test_procurement_rule.py b/purchase_third_party/tests/test_procurement_rule.py index 6dc0011ea..b1fba9f43 100644 --- a/purchase_third_party/tests/test_procurement_rule.py +++ b/purchase_third_party/tests/test_procurement_rule.py @@ -27,7 +27,7 @@ def setUp(self): 0, 0, { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.tp_partner.id, "third_party_price": 5, "price": 7, @@ -41,7 +41,7 @@ def setUp(self): def test_procurement_third_party(self): route = self.env.ref("purchase_stock.route_warehouse0_buy") rule = self.env["stock.rule"].search([("route_id", "=", route.id)], limit=1) - rule.flush() + rule.flush_recordset() procurement = self.env["procurement.group"].Procurement( product_id=self.mto_product, product_qty=1, @@ -51,7 +51,7 @@ def test_procurement_third_party(self): origin="Test", company_id=self.env.user.company_id, values={ - "date_planned": str(Datetime.now()), + "date_planned": Datetime.now(), "company_id": self.env.user.company_id, }, ) diff --git a/purchase_third_party/tests/test_supplier_info.py b/purchase_third_party/tests/test_supplier_info.py index 7ea6b19f4..735171a93 100644 --- a/purchase_third_party/tests/test_supplier_info.py +++ b/purchase_third_party/tests/test_supplier_info.py @@ -24,7 +24,7 @@ def setUp(self): 0, 0, { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.tp_partner.id, "third_party_price": 5, "price": 7, @@ -52,7 +52,7 @@ def test_check_third_party_price(self): 0, 0, { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.tp_partner.id, "third_party_price": False, "price": 7, @@ -65,7 +65,7 @@ def test_check_third_party_price(self): def test_check_third_party_tmpl(self): self.env["product.supplierinfo"].create( { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.tp_partner.id, "third_party_price": 5, "price": 7, @@ -75,7 +75,7 @@ def test_check_third_party_tmpl(self): with self.assertRaises(ValidationError): self.env["product.supplierinfo"].create( { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.supplier.id, "third_party_price": 5, "price": 7, @@ -86,7 +86,7 @@ def test_check_third_party_tmpl(self): def test_check_third_party(self): self.env["product.supplierinfo"].create( { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.tp_partner.id, "third_party_price": 5, "price": 7, @@ -96,7 +96,7 @@ def test_check_third_party(self): with self.assertRaises(ValidationError): self.env["product.supplierinfo"].create( { - "name": self.supplier.id, + "partner_id": self.supplier.id, "third_party_partner_id": self.supplier.id, "third_party_price": 5, "price": 7, diff --git a/purchase_third_party/views/product_supplierinfo_views.xml b/purchase_third_party/views/product_supplierinfo_views.xml index 3b4ae0048..6b9d3a494 100644 --- a/purchase_third_party/views/product_supplierinfo_views.xml +++ b/purchase_third_party/views/product_supplierinfo_views.xml @@ -12,6 +12,7 @@ name="third_party_price" attrs="{'invisible': [('third_party_partner_id', '=', False)]}" /> +
@@ -21,9 +22,11 @@ product.supplierinfo - + + + @@ -32,9 +35,11 @@ product.supplierinfo - + + +