Skip to content
Extraits de code Groupes Projets
Valider 2e8fc04c rédigé par Juliana's avatar Juliana
Parcourir les fichiers

Add Payment term id + change product account

parent 12656277
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,6 +15,7 @@
'data': [
# "security/ir.model.access.csv",
# datas
'data/account_data.xml',
'report/account_invoice_template.xml',
# views
'views/project_views.xml',
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--
Payment terms
-->
<record id="account_payment_term_adefpat" model="account.payment.term">
<field name="name">Conditions Adefpat</field>
<field name="note">Payable à l’ordre de l’ADEFPAT par chèque bancaire ou virement
Banque Crédit Coopératif Toulouse
IBAN : FR76 4255 9100 0008 0124 2734 242
CODE BIC : CCOPFRPPXXX</field>
</record>
</data>
</odoo>
......@@ -11,8 +11,8 @@ class ProductTemplate(models.Model):
# Fields declaration
# ------------------------------------------------------
type_product = fields.Selection([
('physical', 'Personne physique'),
('moral', 'Personne morale')],
('particular', 'Particulier'),
('collectivite', 'Collectivités')],
string="Type de contact")
# ------------------------------------------------------
......
......@@ -61,13 +61,15 @@ class Project(models.Model):
for benef in project.financement_ids:
if benef.partner_id.parent_id:
partner = benef.partner_id.parent_id
# search the product corresponding to the company associated
product_id = self.env['product.product'].search([('type_product', '=', 'moral')])
else:
partner = benef.partner_id
# search the product corresponding to the partner person
product_id = self.env['product.product'].search([('type_product', '=', 'physical')])
if partner.type_structure_id:
# search the product corresponding to the company associated
product_id = self.env['product.product'].search([('type_product', '=', 'collectivite')])
else:
# search the product corresponding to the company associated
product_id = self.env['product.product'].search([('type_product', '=', 'particular')])
# Search if account already exists for the partner of the project
account = self.env['account.invoice'].sudo().search([
('project_id', '=', self.id),
......@@ -83,7 +85,7 @@ class Project(models.Model):
Invoice = self.env['account.invoice']
InvoiceLine = self.env['account.invoice.line']
journal_id = self.env['account.journal'].search([('company_id', '=', self.env.user.company_id.id)], limit=1)
payment_term_id = self.env.ref('adefpat_account.account_payment_term_adefpat')
benef_invoice = Invoice.create({
'name': partner.name,
'project_id': self.id,
......@@ -92,10 +94,12 @@ class Project(models.Model):
'journal_id': journal_id.id,
'state': 'draft',
'account_id': product.property_account_income_id.id,
'payment_term_id': payment_term_id.id
})
# Création de la ligne CG Scop
benef_invoice_line = InvoiceLine.create({
'name': product.name,
'invoice_id': benef_invoice.id,
'product_id': product.id,
'account_id': product.property_account_income_id.id,
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter