Skip to content

Commit

Permalink
[REF] joint_buying_product : rename request_id into transport_request…
Browse files Browse the repository at this point in the history
…_id.
  • Loading branch information
legalsylvain committed Oct 31, 2023
1 parent 1e7951d commit 836edd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions joint_buying_product/models/joint_buying_purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ class JointBuyingPurchaseOrder(models.Model):
selection=_PURCHASE_STATE, required=True, default="draft", track_visibility=True
)

request_id = fields.Many2one(
transport_request_id = fields.Many2one(
comodel_name="joint.buying.transport.request",
string="Transport Request",
readonly=True,
)

request_arrival_date = fields.Datetime(
string="Final Delivery Date",
related="request_id.arrival_date",
related="transport_request_id.arrival_date",
)

pivot_company_id = fields.Many2one(
Expand Down Expand Up @@ -315,14 +315,14 @@ def _hook_state_changed(self):
x.state not in ["closed", "deposited"]
or (x.total_weight or x.amount_untaxed)
)
and not x.request_id
and not x.transport_request_id
and x.deposit_partner_id != x.customer_id
)
if orders_request_to_create:
vals_list = [{"order_id": x.id} for x in orders_request_to_create]
requests = self.env["joint.buying.transport.request"].create(vals_list)
for (order, request) in zip(orders_request_to_create, requests):
order.write({"request_id": request.id})
order.write({"transport_request_id": request.id})

# Unlink transport request:
# - if exist
Expand All @@ -333,7 +333,7 @@ def _hook_state_changed(self):
and not (x.total_weight or x.amount_untaxed)
)
if orders_request_to_unlink:
orders_request_to_unlink.mapped("request_id").unlink()
orders_request_to_unlink.mapped("transport_request_id").unlink()

@api.model_create_multi
def create(self, vals_list):
Expand Down Expand Up @@ -407,7 +407,7 @@ def button_see_request(self):
xml_view = "joint_buying_product.view_joint_buying_transport_request_form"
action = self.env.ref(xml_action).read()[0]
action["views"] = [(self.env.ref(xml_view).id, "form")]
action["res_id"] = self.request_id.id
action["res_id"] = self.transport_request_id.id
return action

@api.multi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def test_10_joint_buying_grouped_order_generate_transport_request(self):
CDA_order = self._get_order_benoit_ronzon("CDA")

# It should generate transport request for CDA and VEV
self.assertTrue(CDA_order.request_id)
self.assertTrue(VEV_order.request_id)
self.assertTrue(CDA_order.transport_request_id)
self.assertTrue(VEV_order.transport_request_id)

# It should not create a transport request for LSE
self.assertFalse(LSE_order.request_id)
self.assertFalse(LSE_order.transport_request_id)
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<field name="request_id" invisible="1"/>
<button type="object" name="button_see_request" class="oe_stat_button" icon="fa-truck" attrs="{'invisible': [('request_id', '=', False)]}" string="Transport Request">
<field name="transport_request_id" invisible="1"/>
<button type="object" name="button_see_request" class="oe_stat_button" icon="fa-truck" attrs="{'invisible': [('transport_request_id', '=', False)]}" string="Transport Request">
</button>
</div>
<div class="oe_title">
Expand Down

0 comments on commit 836edd6

Please sign in to comment.