Browse Source

[ADD] Contract: fiscal position

[ADD] Contract: new contributor

[REF] Contract: indexes
pull/207/head
Thomas Binsfeld 6 years ago
committed by sbejaoui
parent
commit
19b3f50d34
  1. 5
      contract/models/abstract_contract.py
  2. 12
      contract/models/contract.py
  3. 2
      contract/readme/CONTRIBUTORS.rst
  4. 1
      contract/views/contract.xml

5
contract/models/abstract_contract.py

@ -19,7 +19,8 @@ class AbstractAccountAnalyticContract(models.AbstractModel):
name = fields.Char(required=True)
# Needed for avoiding errors on several inherited behaviors
partner_id = fields.Many2one(
comodel_name="res.partner", string="Partner (always False)"
comodel_name="res.partner", string="Partner (always False)",
index=True,
)
pricelist_id = fields.Many2one(
comodel_name='product.pricelist', string='Pricelist'
@ -27,6 +28,7 @@ class AbstractAccountAnalyticContract(models.AbstractModel):
contract_type = fields.Selection(
selection=[('sale', 'Customer'), ('purchase', 'Supplier')],
default='sale',
index=True,
)
journal_id = fields.Many2one(
@ -35,6 +37,7 @@ class AbstractAccountAnalyticContract(models.AbstractModel):
default=lambda s: s._default_journal(),
domain="[('type', '=', contract_type),"
"('company_id', '=', company_id)]",
index=True,
)
company_id = fields.Many2one(
'res.company',

12
contract/models/contract.py

@ -48,9 +48,15 @@ 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'
comodel_name='account.payment.term', string='Payment Terms',
index=True,
)
invoice_count = fields.Integer(compute="_compute_invoice_count")
fiscal_position_id = fields.Many2one(
comodel_name='account.fiscal.position',
string='Fiscal Position',
ondelete='restrict',
)
@api.multi
def _get_related_invoices(self):
@ -151,6 +157,7 @@ class AccountAnalyticAccount(models.Model):
@api.onchange('partner_id')
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
@api.constrains('partner_id', 'recurring_invoices')
def _check_partner_id_recurring_invoices(self):
@ -216,6 +223,7 @@ class AccountAnalyticAccount(models.Model):
'company_id': self.company_id.id,
'user_id': self.partner_id.user_id.id,
'payment_term_id': self.payment_term_id.id,
'fiscal_position_id': self.fiscal_position_id.id,
}
@api.multi
@ -279,8 +287,10 @@ class AccountAnalyticAccount(models.Model):
def _finalize_invoice_creation(self, invoices):
for invoice in invoices:
payment_term = invoice.payment_term_id
fiscal_position = invoice.fiscal_position_id
invoice._onchange_partner_id()
invoice.payment_term_id = payment_term
invoice.fiscal_position_id = fiscal_position
invoices.compute_taxes()
@api.model

2
contract/readme/CONTRIBUTORS.rst

@ -5,3 +5,5 @@
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Miquel Raïch <miquel.raich@eficent.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
* Thomas Binsfeld <thomas.binsfeld@acsone.eu>

1
contract/views/contract.xml

@ -53,6 +53,7 @@
context="{'default_contract_type': contract_type}"/>
<field name="contract_type" invisible="1"
required="1"/>
<field name="fiscal_position_id"/>
</group>
</group>

Loading…
Cancel
Save