[ADD] contract annex
This commit is contained in:
parent
299e8f7c3e
commit
f9b403b570
@ -14,6 +14,7 @@
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"views/res_partner_contract.xml",
|
||||
"views/res_partner_contract_annex.xml",
|
||||
"views/res_partner.xml",
|
||||
"wizard/res_partner_contract_wizard.xml",
|
||||
"data/fields_default.xml",
|
||||
|
@ -1,5 +1,6 @@
|
||||
from . import res_partner
|
||||
from . import res_partner_contract
|
||||
from . import res_partner_contract_annex
|
||||
from . import res_partner_contract_field
|
||||
from . import res_partner_contract_field_transient
|
||||
from . import sale_order
|
||||
|
@ -14,8 +14,11 @@ class PartnerContract(models.Model):
|
||||
help="Field for manual edit when contract is signed or closed",
|
||||
default=lambda self: self.date_conclusion,
|
||||
)
|
||||
order_ids = fields.One2many(
|
||||
"sale.order", "contract_id", string="Annexes", help="Annexes to this contract"
|
||||
contract_annex_ids = fields.One2many(
|
||||
"res.partner.contract.annex",
|
||||
"contract_id",
|
||||
string="Annexes",
|
||||
help="Annexes to this contract",
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
"res.partner",
|
||||
@ -70,15 +73,19 @@ class PartnerContract(models.Model):
|
||||
return "{}-{}".format(date_part, last_contract_number)
|
||||
|
||||
|
||||
class AnnexType(models.Model):
|
||||
_name = "res.partner.contract.annex.type"
|
||||
|
||||
name = fields.Char(string="Annex template name")
|
||||
description = fields.Text(string="Annex template description")
|
||||
|
||||
|
||||
class ContractTemplate(models.Model):
|
||||
_name = "res.partner.contract.template"
|
||||
class PrintTemplateContract(models.Model):
|
||||
_name = "res.partner.template.print.contract"
|
||||
_description = "Print Template Contract"
|
||||
|
||||
attachment_id = fields.Many2one(
|
||||
"ir.attachment", string="Template Attachment", required=True,
|
||||
)
|
||||
is_default = fields.Boolean(string="Default Template", default=False,)
|
||||
|
||||
|
||||
class PrintTemplateAnnex(models.Model):
|
||||
_name = "res.partner.template.print.annex"
|
||||
_description = "Print Template Contract Annex"
|
||||
|
||||
attachment_id = fields.Many2one(
|
||||
"ir.attachment", string="Template Attachment", required=True,
|
||||
|
27
models/res_partner_contract_annex.py
Normal file
27
models/res_partner_contract_annex.py
Normal file
@ -0,0 +1,27 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ContractOrderAnnex(models.Model):
|
||||
_name = "res.partner.contract.annex"
|
||||
_description = "Contract Order Annex"
|
||||
|
||||
name = fields.Char(string="Name", help="The Number of Annex")
|
||||
order_ids = fields.One2many("sale.order", "contract_annex_id", string="Order")
|
||||
contract_id = fields.Many2one(
|
||||
"res.partner.contract", string="Contract", readonly=True
|
||||
)
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
record = super().create(values)
|
||||
|
||||
# Compute name if there is no custom name
|
||||
if not record.name:
|
||||
contract_number = record.contract_id.name
|
||||
annex_number = len(record.contract_id.contract_annex_ids.ids)
|
||||
|
||||
record.name = "{contract}--{annex}".format(
|
||||
contract=contract_number, annex=annex_number
|
||||
)
|
||||
|
||||
return record
|
@ -4,8 +4,6 @@ from odoo import fields, models
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
contract_id = fields.Many2one(
|
||||
"res.partner.contract",
|
||||
string="Contract",
|
||||
help="Contract, assigned to this order",
|
||||
contract_annex_id = fields.Many2one(
|
||||
"res.partner.contract.annex", string="Contract Annex", readonly=True
|
||||
)
|
||||
|
@ -36,7 +36,9 @@
|
||||
<field name="partner_id" readonly="1"/>
|
||||
</group>
|
||||
<group string="Annexed orders" name="multi_params">
|
||||
<field name="order_ids" widget="many2many" attrs="{'readonly': [('state', '=', 'close')]}"/>
|
||||
<field name="contract_annex_ids" attrs="{'readonly': [('state', 'in', ['sign', 'close'])]}">
|
||||
<field name="name"/>
|
||||
</field>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
25
views/res_partner_contract_annex.xml
Normal file
25
views/res_partner_contract_annex.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
|
||||
<!-- res.partner.contract.annex form view -->
|
||||
<record id="res_partner_contract_annex_view_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.contract.annex.view.form</field>
|
||||
<field name="model">res.partner.contract.annex</field>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<form string="Contract Annex">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="contract_id" attrs="{'invisible': [('contract_id', '=', False)]}"/>
|
||||
<field name="order_ids"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
@ -28,9 +28,6 @@ class ContractWizard(models.TransientModel):
|
||||
current_id = self.env.context.get("active_ids")
|
||||
return self.env["res.partner.contract"].browse([current_id[0]]).partner_id.id
|
||||
|
||||
annex_lines = fields.One2many(
|
||||
"res.partner.contract.annex.line", "id", auto_join=True, copy=True
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
"res.partner",
|
||||
string="Company",
|
||||
@ -150,13 +147,3 @@ class ContractWizard(models.TransientModel):
|
||||
"""
|
||||
return math.modf(arg)
|
||||
|
||||
|
||||
class AnnexLine(models.TransientModel):
|
||||
_name = "res.partner.contract.annex.line"
|
||||
|
||||
@api.onchange("annex_type")
|
||||
def _get_default_description(self):
|
||||
self.description = self.annex_type.description
|
||||
|
||||
annex_type = fields.Many2one("res.partner.contract.annex.type")
|
||||
description = fields.Text()
|
||||
|
Loading…
x
Reference in New Issue
Block a user