Skip to content

Commit

Permalink
[IMP] #10761 Add activity user to notify
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiplangat Dan committed Jul 11, 2024
1 parent 18f6cfb commit 7a0b48d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 2 additions & 2 deletions purchase_sale_inter_company/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

from odoo import fields, models


SELECTION_SYNC_FAILURE_ACTIONS = [
("raise", "Block and raise error"),
("notify", "Continue, but create activity to notify someone")
("notify", "Continue, but create activity to notify someone"),
]


Expand Down Expand Up @@ -51,3 +50,4 @@ class ResCompany(models.Model):
block_po_manual_picking_validation = fields.Boolean(
string="Block manual validation of picking in the destination company",
)
notify_user_id = fields.Many2one("res.users", "User to Notify")
6 changes: 6 additions & 0 deletions purchase_sale_inter_company/models/res_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ class InterCompanyRulesConfig(models.TransientModel):
related="company_id.block_po_manual_picking_validation",
readonly=False,
)
notify_user_id = fields.Many2one(
"res.users",
related="company_id.notify_user_id",
help="User to notify incase of sync picking failure.",
readonly=False,
)
7 changes: 5 additions & 2 deletions purchase_sale_inter_company/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def _notify_picking_problem(self, purchase):
note=note,
# Try to notify someone relevant
user_id=(
self.sale_id.user_id.id
self.env.company_id.notify_user_id.id
or self.sale_id.user_id.id
or self.sale_id.team_id.user_id.id
or SUPERUSER_ID,
),
Expand Down Expand Up @@ -144,7 +145,9 @@ def button_validate(self):
if record.company_id.sync_picking_failure_action == "raise":
raise

Check warning on line 146 in purchase_sale_inter_company/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

purchase_sale_inter_company/models/stock_picking.py#L146

Added line #L146 was not covered by tests
else:
record._notify_picking_problem(record.sale_id.auto_purchase_order_id)
record._notify_picking_problem(

Check warning on line 148 in purchase_sale_inter_company/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

purchase_sale_inter_company/models/stock_picking.py#L148

Added line #L148 was not covered by tests
record.sale_id.auto_purchase_order_id
)

# if the flag is set, block the validation of the picking in the destination company
if self.env.company.block_po_manual_picking_validation:
Expand Down
11 changes: 11 additions & 0 deletions purchase_sale_inter_company/views/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@
for="sync_picking_failure_action"
/>
<br />
<label
for="notify_user_id"
class="o_light_label"
attrs="{'invisible': [('sync_picking_failure_action', '!=', 'notify')]}"
/>
<field
name="notify_user_id"
attrs="{'invisible': [('sync_picking_failure_action', '!=', 'notify')], 'required': [('sync_picking_failure_action', '=', 'notify')]}"
class="oe_inline"
/>
<br />
<field
name="block_po_manual_picking_validation"
class="oe_inline"
Expand Down

0 comments on commit 7a0b48d

Please sign in to comment.