mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[REF] - add method to get quantity to invoice
the contract line quantity can be in some use cases variable, to simplify the way it is changed we add a new method _get_quantity_to_invoice.
This commit is contained in:
@@ -48,8 +48,7 @@ class AccountAnalyticAccount(models.Model):
|
||||
compute='_compute_date_end', string='Date End', store=True
|
||||
)
|
||||
payment_term_id = fields.Many2one(
|
||||
comodel_name='account.payment.term', string='Payment Terms',
|
||||
index=True,
|
||||
comodel_name='account.payment.term', string='Payment Terms', index=True
|
||||
)
|
||||
invoice_count = fields.Integer(compute="_compute_invoice_count")
|
||||
fiscal_position_id = fields.Many2one(
|
||||
@@ -63,8 +62,7 @@ class AccountAnalyticAccount(models.Model):
|
||||
ondelete='restrict',
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
inverse='_inverse_partner_id',
|
||||
comodel_name='res.partner', inverse='_inverse_partner_id'
|
||||
)
|
||||
|
||||
@api.multi
|
||||
@@ -72,7 +70,8 @@ class AccountAnalyticAccount(models.Model):
|
||||
for rec in self:
|
||||
if not rec.invoice_partner_id:
|
||||
rec.invoice_partner_id = rec.partner_id.address_get(
|
||||
['invoice'])['invoice']
|
||||
['invoice']
|
||||
)['invoice']
|
||||
|
||||
@api.multi
|
||||
def _get_related_invoices(self):
|
||||
@@ -104,11 +103,16 @@ class AccountAnalyticAccount(models.Model):
|
||||
@api.multi
|
||||
def action_show_invoices(self):
|
||||
self.ensure_one()
|
||||
tree_view_ref = 'account.invoice_supplier_tree' \
|
||||
if self.contract_type == 'purchase' \
|
||||
tree_view_ref = (
|
||||
'account.invoice_supplier_tree'
|
||||
if self.contract_type == 'purchase'
|
||||
else 'account.invoice_tree_with_onboarding'
|
||||
form_view_ref = 'account.invoice_supplier_form' \
|
||||
if self.contract_type == 'purchase' else 'account.invoice_form'
|
||||
)
|
||||
form_view_ref = (
|
||||
'account.invoice_supplier_form'
|
||||
if self.contract_type == 'purchase'
|
||||
else 'account.invoice_form'
|
||||
)
|
||||
tree_view = self.env.ref(tree_view_ref, raise_if_not_found=False)
|
||||
form_view = self.env.ref(form_view_ref, raise_if_not_found=False)
|
||||
action = {
|
||||
@@ -184,12 +188,18 @@ class AccountAnalyticAccount(models.Model):
|
||||
def _onchange_partner_id(self):
|
||||
self.pricelist_id = self.partner_id.property_product_pricelist.id
|
||||
self.fiscal_position_id = self.partner_id.property_account_position_id
|
||||
self.invoice_partner_id = self.partner_id.address_get(
|
||||
['invoice'])['invoice']
|
||||
return {'domain': {'invoice_partner_id': [
|
||||
'|',
|
||||
('id', 'parent_of', self.partner_id.id),
|
||||
('id', 'child_of', self.partner_id.id)]}}
|
||||
self.invoice_partner_id = self.partner_id.address_get(['invoice'])[
|
||||
'invoice'
|
||||
]
|
||||
return {
|
||||
'domain': {
|
||||
'invoice_partner_id': [
|
||||
'|',
|
||||
('id', 'parent_of', self.partner_id.id),
|
||||
('id', 'child_of', self.partner_id.id),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@api.constrains('partner_id', 'recurring_invoices')
|
||||
def _check_partner_id_recurring_invoices(self):
|
||||
|
||||
Reference in New Issue
Block a user