Skip to content

Commit

Permalink
delivery_roulier_picking_batch: add partner on stock_picking_batch, a…
Browse files Browse the repository at this point in the history
…nd improve view
  • Loading branch information
sebastienbeau committed Nov 28, 2024
1 parent 28dddcb commit a3d505c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
12 changes: 12 additions & 0 deletions delivery_roulier_picking_batch/models/stock_picking_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def _get_default_weight_uom(self):
carrier_id = fields.Many2one(
"delivery.carrier", string="Carrier", check_company=True
)
partner_id = fields.Many2one(
"res.partner", string="Delivery Address", check_company=True,
)
weight = fields.Float(
compute="_compute_weight",
digits="Stock Weight",
Expand All @@ -42,6 +45,15 @@ def _get_default_weight_uom(self):
string="Packages",
)

@api.depends("partner_id")
def _compute_allowed_picking_ids(self):
super()._compute_allowed_picking_ids()
for record in self:
if record.partner_id:
record.allowed_picking_ids = record.allowed_picking_ids.filtered(
lambda s: s.partner_id == record.partner_id
)

@api.constrains("carrier_id")
def _check_carrier_id_is_roulier(self):
for batch in self:
Expand Down
37 changes: 34 additions & 3 deletions delivery_roulier_picking_batch/views/stock_picking_batch_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,45 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="stock_picking_batch_tree" model="ir.ui.view">
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch.stock_picking_batch_tree" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="partner_id"/>
<field name="carrier_id"/>
</field>
</field>
</record>

<record id="stock_picking_batch_filter" model="ir.ui.view">
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch.stock_picking_batch_filter" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="partner_id"/>
<field name="carrier_id"/>
</field>
<filter name="user" position="after">
<filter string="Partner" name="partner" domain="[]" context="{'group_by': 'partner_id'}"/>
<filter string="Carrier" name="carrier" domain="[]" context="{'group_by': 'carrier_id'}"/>
</filter>
</field>
</record>


<record id="stock_picking_batch_form" model="ir.ui.view">
<field name="model">stock.picking.batch</field>
<field name="inherit_id" ref="stock_picking_batch.stock_picking_batch_form" />
<field name="arch" type="xml">
<xpath expr="//notebook/page[2]" position="after">
<page string="Additional Info" name="extra">
<xpath expr="//field[@name='user_id']/../.." position="after">
<group>
<group name='carrier_data' string="Shipping Information">
<field
name="partner_id"
attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}"
options="{'no_create': True, 'no_open': True}"
/>
<field
name="carrier_id"
attrs="{'readonly': [('state', 'in', ('done', 'cancel'))]}"
Expand Down Expand Up @@ -45,7 +76,7 @@
/>
</div>
</group>
</page>
</group>
</xpath>
<xpath expr="//div[hasclass('oe_title')]" position="before">
<div class="oe_button_box" name="button_box">
Expand Down

0 comments on commit a3d505c

Please sign in to comment.