Skip to content

Commit

Permalink
[MIG] purchase_sale_inter_company: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongnmtm committed Mar 27, 2024
1 parent 4dd86a6 commit 02d2ae6
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 31 deletions.
4 changes: 4 additions & 0 deletions purchase_sale_inter_company/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ Contributors

- Maksym Yankin <[email protected]>

- \`Komit <https://komit-consulting.com>\`:

- Cuong Nguyen Mtm <[email protected]>

Maintainers
-----------

Expand Down
2 changes: 1 addition & 1 deletion purchase_sale_inter_company/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Inter Company Module for Purchase to Sale Order",
"summary": "Intercompany PO/SO rules",
"version": "16.0.1.1.1",
"version": "17.0.1.0.0",
"category": "Purchase Management",
"website": "https://github.com/OCA/multi-company",
"author": "Odoo SA, Akretion, Tecnativa, Odoo Community Association (OCA)",
Expand Down
3 changes: 2 additions & 1 deletion purchase_sale_inter_company/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def button_cancel(self):
for so in sale_orders:
if so.state not in ["draft", "sent", "cancel"]:
raise UserError(_("You can't cancel an order that is %s") % so.state)
sale_orders.action_cancel()
for so in sale_orders:
so.action_cancel()
self.write({"partner_ref": False})
return super().button_cancel()
2 changes: 2 additions & 0 deletions purchase_sale_inter_company/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
- Pedro M. Baeza
- \`Camptocamp \<<https://www.camptocamp.com>\>\`:
- Maksym Yankin \<<[email protected]>\>
- \`Komit \<<https://komit-consulting.com>\>\`:
- Cuong Nguyen Mtm \<<[email protected]>\>
4 changes: 4 additions & 0 deletions purchase_sale_inter_company/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li>Maksym Yankin &lt;<a class="reference external" href="mailto:maksym.yankin&#64;camptocamp.com">maksym.yankin&#64;camptocamp.com</a>&gt;</li>
</ul>
</li>
<li>`Komit &lt;<a class="reference external" href="https://komit-consulting.com">https://komit-consulting.com</a>&gt;`:<ul>
<li>Cuong Nguyen Mtm &lt;<a class="reference external" href="mailto:cuong.nmtm&#64;komit-consulting.com">cuong.nmtm&#64;komit-consulting.com</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def setUpClass(cls):
# Create purchase order
cls.purchase_company_a = cls._create_purchase_order(cls.partner_company_b)

# Configure pricelist to USD
# Configure pricelist to EUR
cls.env["product.pricelist"].sudo().search([]).write(
{"currency_id": cls.env.ref("base.USD").id}
{"currency_id": cls.env.ref("base.EUR").id}
)

def _approve_po(self):
Expand Down Expand Up @@ -128,7 +128,7 @@ def test_raise_product_access(self):
self._approve_po()

def test_raise_currency(self):
currency = self.env.ref("base.EUR")
currency = self.env.ref("base.USD")
self.purchase_company_a.currency_id = currency
with self.assertRaises(UserError):
self._approve_po()
Expand Down Expand Up @@ -162,6 +162,7 @@ def test_cancel_confirmed_po_so(self):
self.purchase_company_a.with_user(self.user_company_a).button_cancel()

def test_so_change_price(self):
self.company_b.sale_auto_validation = False
sale = self._approve_po()
sale.order_line.price_unit = 10
sale.action_confirm()
Expand All @@ -182,6 +183,7 @@ def test_update_open_sale_order(self):
When the purchase user request extra product, the sale order gets synched if
it's open.
"""
self.company_b.sale_auto_validation = False
purchase = self.purchase_company_a
sale = self._approve_po()
sale.action_confirm()
Expand Down
54 changes: 28 additions & 26 deletions purchase_sale_inter_company/views/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@
ref="account_invoice_inter_company.res_config_settings_view_form"
/>
<field name="arch" type="xml">
<xpath
expr="//div[@id='inter_company_invoice_validation']"
position='after'
>
<div class="o_form_label mt8">Purchase/Sale</div>
<div id="inter_company_so_from_po">
<field name="so_from_po" class="oe_inline" />
<label
string="Sale from purchase"
class="o_light_label"
for="so_from_po"
/>
</div>
<div
id="inter_company_settings"
attrs="{'invisible':['|', ('company_id', '=', False), ('so_from_po', '=', False)]}"
>
<label for="intercompany_sale_user_id" class="o_light_label" />
<field
name="intercompany_sale_user_id"
attrs="{'required': [('so_from_po', '=', True)]}"
class="oe_inline"
/>
<br />
<field name="sale_auto_validation" class="oe_inline" />
<label for="sale_auto_validation" class="oe_inline o_light_label" />
<xpath expr="//setting[@id='inter_company_oca']" position='inside'>
<div class="text-decoration-underline mt8 mb8">Purchase / Sale</div>
<div class="content-group">
<div>
<label
string="Sale from purchase"
class="o_light_label mr8"
for="so_from_po"
/>
<field name="so_from_po" class="oe_inline" />
</div>
<div invisible="not company_id or not so_from_po">
<label
for="intercompany_sale_user_id"
class="o_light_label mr8"
/>
<field
name="intercompany_sale_user_id"
required="so_from_po"
class="oe_inline mr8"
/>
<br />
<label
for="sale_auto_validation"
class="oe_inline o_light_label mr8"
/>
<field name="sale_auto_validation" class="oe_inline" />
</div>
</div>
</xpath>
</field>
Expand Down

0 comments on commit 02d2ae6

Please sign in to comment.