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

[14.0] No automatic done state #6

Closed
wants to merge 4 commits into from
Closed
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
7 changes: 7 additions & 0 deletions purchase_sale_inter_company/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class ResCompany(models.Model):
default="raise",
help="Pick action to perform on sync picking failure",
)
sync_picking_state = fields.Boolean(
string="Sync the receipt state with the delivery state",
default=lambda p: p.sync_picking,
help="State of receipt picking syncs with state of the delivery "
"from the source company. Note this disallows user to manually "
"correct or change a picking that did not sync properly.",
)
block_po_manual_picking_validation = fields.Boolean(
string="Block manual validation of picking in the destination company",
)
Expand Down
3 changes: 3 additions & 0 deletions purchase_sale_inter_company/models/res_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class InterCompanyRulesConfig(models.TransientModel):
)
sync_picking_failure_action = fields.Selection(
related="company_id.sync_picking_failure_action",
)
sync_picking_state = fields.Boolean(
related="company_id.sync_picking_state",
readonly=False,
)
block_po_manual_picking_validation = fields.Boolean(
Expand Down
3 changes: 2 additions & 1 deletion purchase_sale_inter_company/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def _compute_state(self):
res = super()._compute_state()
for picking in self:
if (
picking.intercompany_picking_id
picking.company_id.sync_picking_state
and picking.intercompany_picking_id
and picking.picking_type_code == "incoming"
and picking.state not in ["done", "cancel"]
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def test_confirm_several_picking(self):
def test_sync_picking(self):
self.company_a.sync_picking = True
self.company_b.sync_picking = True
self.company_a.sync_picking_state = True
self.company_b.sync_picking_state = True

purchase = self._create_purchase_order(
self.partner_company_b, self.consumable_product
Expand Down Expand Up @@ -378,10 +380,15 @@ def test_sync_picking(self):
# A backorder should have been made for both
self.assertTrue(len(sale.picking_ids) > 1)
self.assertEqual(len(purchase.picking_ids), len(sale.picking_ids))
# The original orders should now be done.
self.assertEqual(so_picking_id.state, "done")
self.assertEqual(po_picking_id.state, "done")

def test_sync_picking_no_backorder(self):
self.company_a.sync_picking = True
self.company_b.sync_picking = True
self.company_a.sync_picking_state = True
self.company_b.sync_picking_state = True

purchase = self._create_purchase_order(
self.partner_company_b, self.consumable_product
Expand Down Expand Up @@ -455,6 +462,8 @@ def test_sync_picking_lot(self):
)
self.company_a.sync_picking = True
self.company_b.sync_picking = True
self.company_a.sync_picking_state = True
self.company_b.sync_picking_state = True

purchase = self._create_purchase_order(
self.partner_company_b,
Expand Down Expand Up @@ -529,6 +538,9 @@ def test_sync_picking_lot(self):
# A backorder should have been made for both
self.assertTrue(len(sale.picking_ids) > 1)
self.assertEqual(len(purchase.picking_ids), len(sale.picking_ids))
# The original orders should now be done.
self.assertEqual(so_picking_id.state, "done")
self.assertEqual(po_picking_id.state, "done")

def test_sync_picking_same_product_multiple_lines(self):
"""
Expand Down Expand Up @@ -661,6 +673,10 @@ def test_update_open_sale_order(self):
"3.0 Units of Consumable Product 2.+instead of 8.0 Units", re.DOTALL
),
)
print(so_picking_id.state)
po_picking_id = purchase.picking_ids
print(po_picking_id.state)
# Upon confirm, I expect here an issue

def test_block_manual_validation(self):
"""
Expand All @@ -669,6 +685,8 @@ def test_block_manual_validation(self):
"""
self.company_a.sync_picking = True
self.company_b.sync_picking = True
self.company_a.sync_picking_state = True
self.company_b.sync_picking_state = True
self.company_a.block_po_manual_picking_validation = True
self.company_b.block_po_manual_picking_validation = True
purchase = self._create_purchase_order(
Expand Down
6 changes: 6 additions & 0 deletions purchase_sale_inter_company/views/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
attrs="{'invisible': [('sync_picking_failure_action', '!=', 'notify')], 'required': [('sync_picking_failure_action', '=', 'notify')]}"
class="oe_inline"
/>
<field name="sync_picking_state" class="oe_inline" />
<label
string="Sync picking state"
class="o_light_label"
for="sync_picking_state"
/>
<br />
<field
name="block_po_manual_picking_validation"
Expand Down
Loading