mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] sale_credit_limit: add partner fields and sale exceptions
H4721
This commit is contained in:
@@ -13,7 +13,32 @@ partner_balance = partner.credit + sale.amount_total
|
|||||||
if partner.credit_limit and partner.credit_limit <= partner_balance:
|
if partner.credit_limit and partner.credit_limit <= partner_balance:
|
||||||
failed = True
|
failed = True
|
||||||
</field>
|
</field>
|
||||||
<field name="active" eval="True" />
|
</record>
|
||||||
|
|
||||||
|
<record id="excep_sale_credit_hold" model="exception.rule">
|
||||||
|
<field name="name">Customer On Credit Hold.</field>
|
||||||
|
<field name="description">The Customer is on Credit Hold.
|
||||||
|
Please have the customer contact accounting.</field>
|
||||||
|
<field name="sequence">50</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="code">
|
||||||
|
partner = sale.partner_invoice_id.commercial_partner_id
|
||||||
|
if partner.credit_hold:
|
||||||
|
failed = True
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="excep_invoice_overdue" model="exception.rule">
|
||||||
|
<field name="name">Customer has Overdue Invoices.</field>
|
||||||
|
<field name="description">The Customer has unpaid overdue invoices.
|
||||||
|
Please have the customer contact accounting.</field>
|
||||||
|
<field name="sequence">55</field>
|
||||||
|
<field name="model">sale.order</field>
|
||||||
|
<field name="code">
|
||||||
|
partner = sale.partner_invoice_id.commercial_partner_id
|
||||||
|
if partner.invoice_ids.filtered(lambda i: i.state == 'posted' and i.invoice_payment_state != 'paid' and (i.invoice_date_due and str(i.invoice_date_due) < time.strftime('%Y-%m-%d',time.gmtime())) and i.type == 'out_invoice'):
|
||||||
|
failed = True
|
||||||
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -1 +1,2 @@
|
|||||||
|
from . import partner
|
||||||
from . import sale
|
from . import sale
|
||||||
|
|||||||
16
sale_credit_limit/models/partner.py
Normal file
16
sale_credit_limit/models/partner.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResPartner(models.Model):
|
||||||
|
_inherit = 'res.partner'
|
||||||
|
|
||||||
|
credit_remaining = fields.Float('Credit Remaining', compute='_compute_credit_remaining')
|
||||||
|
credit_hold = fields.Boolean('Credit Hold')
|
||||||
|
|
||||||
|
@api.depends('credit_limit', 'credit')
|
||||||
|
def _compute_credit_remaining(self):
|
||||||
|
for partner in self:
|
||||||
|
if partner.credit_limit:
|
||||||
|
partner.credit_remaining = partner.credit_limit - partner.credit
|
||||||
|
else:
|
||||||
|
partner.credit_remaining = 0.0
|
||||||
@@ -7,7 +7,10 @@
|
|||||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//group[@name='accounting_entries']" position="inside">
|
<xpath expr="//group[@name='accounting_entries']" position="inside">
|
||||||
<field name="credit_limit" widget="monetary" attrs="{'invisible': [('parent_id', '!=', False)]}"/>
|
<field name="credit" widget="monetary" attrs="{'invisible': [('parent_id', '!=', False)]}" groups="account.group_account_user"/>
|
||||||
|
<field name="credit_limit" attrs="{'invisible': [('parent_id', '!=', False)]}" groups="account.group_account_user"/>
|
||||||
|
<field name="credit_remaining" widget="monetary" attrs="{'invisible': [('parent_id', '!=', False)]}" groups="account.group_account_user"/>
|
||||||
|
<field name="credit_hold" attrs="{'invisible': [('parent_id', '!=', False)]}" groups="account.group_account_user"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user