module can be installd
This commit is contained in:
parent
dff9d75217
commit
c21103cab7
@ -7,6 +7,6 @@ class ProductProduct(models.Model):
|
|||||||
description_sale = fields.Text(
|
description_sale = fields.Text(
|
||||||
"Sale Description",
|
"Sale Description",
|
||||||
translate=True,
|
translate=True,
|
||||||
help="A description of the Product that you want to communicate to your customers. "
|
help="A product's description you want to inform to your customers.\n"
|
||||||
"This description will be copied to every Sales Order, Delivery Order and Customer Invoice/Credit Note",
|
"This description will be copied to every Sales Order, Delivery Order and Customer Invoice/Credit Note",
|
||||||
)
|
)
|
||||||
|
@ -3,13 +3,13 @@ import datetime
|
|||||||
from odoo import _, fields, models
|
from odoo import _, fields, models
|
||||||
|
|
||||||
from ..utils import MODULE_NAME
|
from ..utils import MODULE_NAME
|
||||||
from ..utils.misc import Extension, IDocument
|
# from ..utils.misc import Extension, IDocument
|
||||||
|
|
||||||
|
|
||||||
class PartnerContract(models.Model, IDocument, Extension):
|
class PartnerContract(models.Model): #, IDocument, Extension):
|
||||||
_name = "res.partner.contract"
|
_name = "res.partner.contract"
|
||||||
_description = "Contract"
|
_description = "Contract"
|
||||||
_inherit = ["mail.thread", "mail.activity.mixin", "mail.followers"]
|
_inherit = ["mail.thread", "mail.activity.mixin", "mail.followers", "client_contracts.utils"]
|
||||||
|
|
||||||
def _get_default_name(self):
|
def _get_default_name(self):
|
||||||
"""Returns name format `№YYMM-D-N`,
|
"""Returns name format `№YYMM-D-N`,
|
||||||
@ -43,7 +43,7 @@ class PartnerContract(models.Model, IDocument, Extension):
|
|||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
"res.partner",
|
"res.partner",
|
||||||
string="Company",
|
string="Company",
|
||||||
default=lambda self: self.env.user.company_id.partner_id,
|
default=lambda self: self.env.company.partner_id,
|
||||||
)
|
)
|
||||||
create_date_ts = fields.Char(default=_get_default_create_date_ts)
|
create_date_ts = fields.Char(default=_get_default_create_date_ts)
|
||||||
res_model = fields.Char(default=lambda self: self._name)
|
res_model = fields.Char(default=lambda self: self._name)
|
||||||
@ -79,7 +79,7 @@ class PartnerContract(models.Model, IDocument, Extension):
|
|||||||
readonly=True,
|
readonly=True,
|
||||||
copy=False,
|
copy=False,
|
||||||
index=True,
|
index=True,
|
||||||
track_visibility="onchange",
|
tracking=True,
|
||||||
track_sequence=3,
|
track_sequence=3,
|
||||||
default="draft",
|
default="draft",
|
||||||
)
|
)
|
||||||
|
@ -3,11 +3,12 @@ import math
|
|||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
|
||||||
from ..utils import MODULE_NAME
|
from ..utils import MODULE_NAME
|
||||||
from ..utils.misc import Extension, IDocument
|
# from ..utils.misc import Extension, IDocument
|
||||||
|
|
||||||
|
|
||||||
class ContractOrderAnnex(models.Model, IDocument, Extension):
|
class ContractOrderAnnex(models.Model): # , IDocument, Extension):
|
||||||
_name = "res.partner.contract.annex"
|
_name = "res.partner.contract.annex"
|
||||||
|
_inherit = ["client_contracts.utils"]
|
||||||
_description = "Contract Annex"
|
_description = "Contract Annex"
|
||||||
|
|
||||||
name = fields.Char(
|
name = fields.Char(
|
||||||
@ -85,12 +86,18 @@ class ContractOrderAnnex(models.Model, IDocument, Extension):
|
|||||||
string="Total Cost",
|
string="Total Cost",
|
||||||
)
|
)
|
||||||
|
|
||||||
payment_part_one = fields.Float(string="Payment 1 Part (%)", default=100)
|
payment_part_one = fields.Float(
|
||||||
|
string="Payment 1 Part (%)",
|
||||||
|
default=100,
|
||||||
|
digits="Account",
|
||||||
|
)
|
||||||
payment_part_two = fields.Float(
|
payment_part_two = fields.Float(
|
||||||
string="Payment 2 Part (%)",
|
string="Payment 2 Part (%)",
|
||||||
|
digits="Account",
|
||||||
)
|
)
|
||||||
payment_part_three = fields.Float(
|
payment_part_three = fields.Float(
|
||||||
string="Payment 3 Part (%)",
|
string="Payment 3 Part (%)",
|
||||||
|
digits="Account",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.depends("name")
|
@api.depends("name")
|
||||||
@ -134,14 +141,11 @@ class ContractOrderAnnex(models.Model, IDocument, Extension):
|
|||||||
@api.model
|
@api.model
|
||||||
def create(self, values):
|
def create(self, values):
|
||||||
record = super().create(values)
|
record = super().create(values)
|
||||||
|
|
||||||
# Fill annex_id to domain it in future
|
# Fill annex_id to domain it in future
|
||||||
record.order_id.contract_annex_id = record.id
|
record.order_id.contract_annex_id = record.id
|
||||||
|
|
||||||
# Counter
|
# Counter
|
||||||
record.counter = record.contract_id.contract_annex_number
|
record.counter = record.contract_id.contract_annex_number
|
||||||
record.contract_id.contract_annex_number += 1 # TODO: should I use a sequence?
|
record.contract_id.contract_annex_number += 1 # TODO: should I use a sequence?
|
||||||
|
|
||||||
return record
|
return record
|
||||||
|
|
||||||
def action_print_form(self):
|
def action_print_form(self):
|
||||||
|
@ -6,3 +6,4 @@ access_contracts_field_transient,access_contracts_field_transient,model_res_part
|
|||||||
access_contracts_field_contract_annex,access_contracts_field_contract_annex,model_res_partner_contract_annex,base.group_user,1,1,1,1
|
access_contracts_field_contract_annex,access_contracts_field_contract_annex,model_res_partner_contract_annex,base.group_user,1,1,1,1
|
||||||
access_contract_document_template,access_contract_document_template,model_res_partner_document_template,base.group_user,1,0,0,0
|
access_contract_document_template,access_contract_document_template,model_res_partner_document_template,base.group_user,1,0,0,0
|
||||||
access_contract_document_template_manager,access_contract_document_template,model_res_partner_document_template,hr.group_hr_manager,1,1,1,1
|
access_contract_document_template_manager,access_contract_document_template,model_res_partner_document_template,hr.group_hr_manager,1,1,1,1
|
||||||
|
access_contracts_wizard,access_contracts_wizard,model_res_partner_contract_wizard,base.group_user,1,1,1,1
|
||||||
|
|
@ -1 +1,3 @@
|
|||||||
|
from . import misc
|
||||||
|
|
||||||
MODULE_NAME = __package__.split(".")[-2]
|
MODULE_NAME = __package__.split(".")[-2]
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import datetime as dt
|
import datetime as dt
|
||||||
import inspect
|
# import inspect
|
||||||
|
|
||||||
from odoo import fields
|
from odoo import models # , fields
|
||||||
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||||
|
|
||||||
|
|
||||||
class IDocument(object):
|
'''class IDocument(object):
|
||||||
"""Class must be used as an interface for create new document based model"""
|
"""Class must be used as an interface for create new document based model"""
|
||||||
|
|
||||||
def get_name_by_document_template(self, document_template_id: fields.Many2one):
|
def get_name_by_document_template(self, document_template_id: fields.Many2one):
|
||||||
@ -16,17 +16,22 @@ class IDocument(object):
|
|||||||
def get_filename_by_document_template(self, document_template_id: fields.Many2one):
|
def get_filename_by_document_template(self, document_template_id: fields.Many2one):
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
||||||
)
|
)'''
|
||||||
|
|
||||||
|
|
||||||
class Extension(object):
|
class Utils(models.AbstractModel):
|
||||||
def parse_odoo_date(self, date: str):
|
_name = "client_contracts.utils"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def parse_odoo_date(date: str):
|
||||||
return dt.datetime.strptime(date, DEFAULT_SERVER_DATE_FORMAT)
|
return dt.datetime.strptime(date, DEFAULT_SERVER_DATE_FORMAT)
|
||||||
|
|
||||||
def parse_odoo_datetime(self, datetime: str):
|
@staticmethod
|
||||||
|
def parse_odoo_datetime(datetime: str):
|
||||||
return dt.datetime.strptime(datetime, DEFAULT_SERVER_DATETIME_FORMAT)
|
return dt.datetime.strptime(datetime, DEFAULT_SERVER_DATETIME_FORMAT)
|
||||||
|
|
||||||
def to_fixed(self, number, digit=2):
|
@staticmethod
|
||||||
|
def to_fixed(number, digit=2):
|
||||||
if isinstance(number, str) and number.isdigit():
|
if isinstance(number, str) and number.isdigit():
|
||||||
number = float(number)
|
number = float(number)
|
||||||
return format(number, ".{digit}f".format(digit=digit))
|
return format(number, ".{digit}f".format(digit=digit))
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">res.partner.contract.field</field>
|
<field name="res_model">res.partner.contract.field</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- res.partner.document.template action window -->
|
<!-- res.partner.document.template action window -->
|
||||||
@ -16,7 +15,6 @@
|
|||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">res.partner.document.template</field>
|
<field name="res_model">res.partner.document.template</field>
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="res_partner_contract_info_inherit_view" model="ir.ui.view">
|
<record id="res_partner_contract_info_inherit_view" model="ir.ui.view">
|
||||||
@ -66,11 +64,11 @@
|
|||||||
<field name="priority" eval="25"/>
|
<field name="priority" eval="25"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
<button name="toggle_active" position="before">
|
<xpath expr="//div[@name='button_box']" position="inside">
|
||||||
<button class="oe_inline oe_stat_button" type="action" name="%(res_partner_contract_partner_action)d" attrs="{'invisible': [('customer', '=', False)]}" icon="fa-pencil-square-o">
|
<button class="oe_inline oe_stat_button" type="action" name="%(res_partner_contract_partner_action)d" attrs="{'invisible': [('parent_id', '!=', False)]}" icon="fa-pencil-square-o">
|
||||||
<field string="Contracts" name="contract_count" widget="statinfo"/>
|
<field string="Contracts" name="contract_count" widget="statinfo"/>
|
||||||
</button>
|
</button>
|
||||||
</button>
|
</xpath>
|
||||||
|
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -87,7 +87,6 @@
|
|||||||
<record id="res_partner_contract_action" model="ir.actions.act_window">
|
<record id="res_partner_contract_action" model="ir.actions.act_window">
|
||||||
<field name="name">Contracts</field>
|
<field name="name">Contracts</field>
|
||||||
<field name="res_model">res.partner.contract</field>
|
<field name="res_model">res.partner.contract</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{}</field>
|
<field name="context">{}</field>
|
||||||
</record>
|
</record>
|
||||||
@ -95,7 +94,6 @@
|
|||||||
<record id="res_partner_contract_partner_action" model="ir.actions.act_window">
|
<record id="res_partner_contract_partner_action" model="ir.actions.act_window">
|
||||||
<field name="name">Contracts</field>
|
<field name="name">Contracts</field>
|
||||||
<field name="res_model">res.partner.contract</field>
|
<field name="res_model">res.partner.contract</field>
|
||||||
<field name="view_type">form</field>
|
|
||||||
<field name="view_mode">tree,form</field>
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="context">{'search_default_partner_id': active_id}</field>
|
<field name="context">{'search_default_partner_id': active_id}</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -6,13 +6,14 @@ from odoo.exceptions import ValidationError
|
|||||||
|
|
||||||
from ..utils import MODULE_NAME
|
from ..utils import MODULE_NAME
|
||||||
from ..utils.docxtpl import get_document_from_values_stream
|
from ..utils.docxtpl import get_document_from_values_stream
|
||||||
from ..utils.misc import Extension
|
# from ..utils.misc import Extension
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ContractWizard(models.TransientModel, Extension):
|
class ContractWizard(models.TransientModel): #, Extension):
|
||||||
_name = "res.partner.contract.wizard"
|
_name = "res.partner.contract.wizard"
|
||||||
|
_inherit = ["client_contracts.utils"]
|
||||||
|
|
||||||
def _default_target(self):
|
def _default_target(self):
|
||||||
return "{model},{target_id}".format(
|
return "{model},{target_id}".format(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user