[imp] add credit warning
This commit is contained in:
parent
a35104c7f8
commit
51b505ba23
2 changed files with 33 additions and 18 deletions
|
|
@ -50,6 +50,7 @@ class SaleOrderBatch(models.Model):
|
|||
amount_total = fields.Float(compute="_compute_amount_total", string="Total")
|
||||
product_ids = fields.One2many("sale.order.batch.product", "batch_id")
|
||||
product_count = fields.Integer(compute="_compute_product_count")
|
||||
partner_credit_warning = fields.Text(compute="_compute_partner_credit_warning")
|
||||
|
||||
@api.depends("sale_order_ids.validity_date")
|
||||
def _compute_validity_date(self):
|
||||
|
|
@ -80,6 +81,14 @@ class SaleOrderBatch(models.Model):
|
|||
for batch in self:
|
||||
batch.product_count = len(batch.product_ids)
|
||||
|
||||
@api.depends("sale_order_ids.partner_credit_warning")
|
||||
def _compute_partner_credit_warning(self):
|
||||
for batch in self:
|
||||
batch.partner_credit_warning = ""
|
||||
for order in batch.sale_order_ids:
|
||||
if order.partner_credit_warning:
|
||||
batch.partner_credit_warning += order.partner_credit_warning + "\n"
|
||||
|
||||
def action_view_source_sale_orders(self):
|
||||
self.ensure_one()
|
||||
result = self.env["ir.actions.act_window"]._for_xml_id("sale.action_orders")
|
||||
|
|
|
|||
|
|
@ -31,8 +31,15 @@
|
|||
/>
|
||||
<field name="state" widget="statusbar" options="{'clickable': 'true'}"/>
|
||||
</header>
|
||||
<div
|
||||
class="alert alert-warning mb-0"
|
||||
role="alert"
|
||||
attrs="{'invisible': [('partner_credit_warning', '=', '')]}"
|
||||
>
|
||||
<field name="partner_credit_warning"/>
|
||||
</div>
|
||||
<sheet>
|
||||
<div name="button_box">
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button
|
||||
class="oe_stat_button"
|
||||
type="object"
|
||||
|
|
@ -57,12 +64,7 @@
|
|||
</h1>
|
||||
<group>
|
||||
<group>
|
||||
<field
|
||||
name="sale_order_ids"
|
||||
widget="many2many_tags"
|
||||
domain="[('state','in',['draft','sent']),('batch_id','=',False)]"
|
||||
attrs="{'readonly': [('state','=','closed')]}"
|
||||
/>
|
||||
<field name="amount_total" colspan="2" readonly="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="date_order" attrs="{'readonly': [('state','=','closed')]}"/>
|
||||
|
|
@ -70,6 +72,20 @@
|
|||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Sale Orders" name="orders">
|
||||
<field
|
||||
name="sale_order_ids"
|
||||
domain="[('state','in',['draft','sent']),('batch_id','=',False)]"
|
||||
attrs="{'readonly': [('state', 'in', ('closed'))]}"
|
||||
>
|
||||
<tree>
|
||||
<field name="partner_id"/>
|
||||
<field name="date_order"/>
|
||||
<field name="amount_untaxed"/>
|
||||
<field name="amount_total"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Sale Order Lines" name="order_line">
|
||||
<field
|
||||
name="sale_order_line_ids"
|
||||
|
|
@ -86,24 +102,14 @@
|
|||
<field name="price_subtotal"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group name="note_group" col="6" class="mt-2 mt-md-0">
|
||||
<group colspan="4">
|
||||
</group>
|
||||
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
|
||||
<field name="amount_total" colspan="2" readonly="1"/>
|
||||
</group>
|
||||
<div class="clearfix"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Products" name="products">
|
||||
<field name="product_ids">
|
||||
<tree create="0" editable="1">
|
||||
<field name="product_template_id"/>
|
||||
<field name="product_uom_category_id"/>
|
||||
<field name="product_uom_qty"/>
|
||||
<field name="product_uom"/>
|
||||
<field name="product_packaging_id" groups="product.group_stock_packaging"/>
|
||||
<field name="product_packaging_qty" groups="product.group_stock_packaging"/>
|
||||
<field name="product_packaging_id" groups="product.group_stock_packaging"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
|
|
|||
Loading…
Reference in a new issue