Skip to content
Snippets Groups Projects
Commit d176397b authored by Juliana's avatar Juliana
Browse files

[ADD]Add ref productor

parent 49e4a2be
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
"security/ir.model.access.csv",
# datas
"data/mail_data.xml",
"data/data.xml",
# views
"views/res_partner_views.xml",
"views/acc_operation_views.xml",
......
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="sequence_prod_seq" model="ir.sequence">
<field name="name">Séquence pour les producteurs</field>
<field name="code">res.partner</field>
<field name="prefix">P</field>
<field name="padding">4</field>
<field eval="False" name="company_id"/>
</record>
</data>
</odoo>
# Copyright 2021 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
from odoo import fields, models, api
class ResPartner(models.Model):
......@@ -34,6 +34,7 @@ class ResPartner(models.Model):
)
mail_contact_pmo = fields.Char("Mail du contact PMO")
date_log = fields.Datetime("Date de connexion")
ref_producer = fields.Char("Référence du producteur")
# ------------------------------------------------------
# SQL Constraints
# ------------------------------------------------------
......@@ -53,7 +54,12 @@ class ResPartner(models.Model):
# ------------------------------------------------------
# CRUD methods (ORM overrides)
# ------------------------------------------------------
@api.model
def create(self, vals):
if vals.get("is_producer") == True:
vals["ref_producer"] = self.env["ir.sequence"].next_by_code("res.partner")
result = super(ResPartner, self).create(vals)
return result
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
......
......@@ -51,6 +51,7 @@
<field name="arch" type="xml">
<field name="type" position="before">
<field name="is_producer" />
<field name="ref_producer" attrs="{'invisible': [('is_producer', '!=', True)]}"/>
<field name="is_consumer" />
<field name="is_pmo" />
<field
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment