From 60d415192b62c981af3d52acf07e1e670630eeb0 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Mon, 3 May 2021 23:17:54 +0500 Subject: [PATCH] docs creating works except ir.actions.run, 615 str --- data/fields_default.xml | 2 +- models/product_product.py | 2 +- models/res_partner.py | 4 ++-- models/res_partner_contract.py | 15 ++++++--------- models/res_partner_contract_annex.py | 10 +++++----- models/sale_order.py | 3 ++- utils/misc.py | 4 ++-- views/res_partner.xml | 4 +--- wizard/res_partner_contract_wizard.py | 6 ++++-- 9 files changed, 24 insertions(+), 26 deletions(-) diff --git a/data/fields_default.xml b/data/fields_default.xml index 5fac1da..86755f6 100755 --- a/data/fields_default.xml +++ b/data/fields_default.xml @@ -187,7 +187,7 @@ MM = months[mm] dd = dd if dd // 10 else '0{}'.format(dd) mm = mm if mm // 10 else '0{}'.format(mm) -order_date = self.parse_odoo_datetime(self.order_id.date_order) +order_date = self.order_id.date_order # ctx keys must be decalared in this xml with id equal to "contract_field_{technical_name}" ctx = { diff --git a/models/product_product.py b/models/product_product.py index 126988d..71a55ef 100644 --- a/models/product_product.py +++ b/models/product_product.py @@ -7,6 +7,6 @@ class ProductProduct(models.Model): description_sale = fields.Text( "Sale Description", translate=True, - help="A product's description you want to inform to your customers.\n" + help="A product's description you want to tell to your customers.\n" "This description will be copied to every Sales Order, Delivery Order and Customer Invoice/Credit Note", ) diff --git a/models/res_partner.py b/models/res_partner.py index f41ebaa..fe16a39 100755 --- a/models/res_partner.py +++ b/models/res_partner.py @@ -15,7 +15,7 @@ class ResPartner(models.Model): string="Name Initials", ) function_genitive = fields.Char( - string="Function Genitive", + string="Job position genitive", ) client_contract_ids = fields.One2many( "res.partner.contract", @@ -33,7 +33,7 @@ class ResPartner(models.Model): string="Actual Address", ) representative_id = fields.Many2one( - "res.partner", string="Representative", help="Person, who represents company" + "res.partner", string="Representative", help="Person representing company" ) representative_document = fields.Char( string="Representative acts on the basis of", diff --git a/models/res_partner_contract.py b/models/res_partner_contract.py index e4c8864..a158e3a 100755 --- a/models/res_partner_contract.py +++ b/models/res_partner_contract.py @@ -36,7 +36,8 @@ class PartnerContract(models.Model): # , IDocument, Extension): return contract_date - def _get_default_create_date_ts(self): + @staticmethod + def _get_default_create_date_ts(): """Returns timestamp of now by local datetime""" return datetime.datetime.now().timestamp() @@ -59,11 +60,11 @@ class PartnerContract(models.Model): # , IDocument, Extension): ) create_date = fields.Datetime(string="Created on") date_conclusion = fields.Date( - string="Date of system conclusion", + string="Signing date in system", ) date_conclusion_fix = fields.Date( - string="Date of manual conclusion", - help="Field for manual edit when contract is signed or closed", + string="Actual signing date", + help="Field for pointing out manually when contract is signed or closed", default=lambda self: self.date_conclusion, ) contract_annex_ids = fields.One2many( @@ -140,11 +141,7 @@ class PartnerContract(models.Model): # , IDocument, Extension): datetime.datetime -- date_conclusion_fix or date_conclusion or create_date """ date = self.date_conclusion_fix or self.date_conclusion - if date: - date = self.parse_odoo_date(date) - else: - date = self.parse_odoo_datetime(self.create_date) - return date + return date or self.create_date def _(self, arg): """Uses in xml action (data/fields_default) diff --git a/models/res_partner_contract_annex.py b/models/res_partner_contract_annex.py index b2f491c..7665048 100755 --- a/models/res_partner_contract_annex.py +++ b/models/res_partner_contract_annex.py @@ -38,20 +38,20 @@ class ContractOrderAnnex(models.Model): # , IDocument, Extension): order_id = fields.Many2one( "sale.order", string="Order", - help="Orders with this partner which are not uses in annexes yet", + help="This partner's orders which are not used in annexes yet", required=True, ) date_conclusion = fields.Date( - string="Conclusion Date", + string="Signing Date", default=fields.Date.today(), ) counter = fields.Integer( string="№", - help="Counter of Contract Annexes", + help="Contract Annexes counter", ) currency_id = fields.Many2one( - related="company_id.currency_id", - readonly=True, + string="Currency", + default=lambda self: self.env.company.currency_id, ) design_period = fields.Integer( diff --git a/models/sale_order.py b/models/sale_order.py index b6dd0e0..3c2ea5c 100755 --- a/models/sale_order.py +++ b/models/sale_order.py @@ -6,6 +6,7 @@ from ..utils import MODULE_NAME class SaleOrder(models.Model): _inherit = "sale.order" + # TODO: exists original field "commitment_date". delivery_time = fields.Integer( string="Delivery Time", default=45, @@ -15,7 +16,7 @@ class SaleOrder(models.Model): string="Contract Annex", readonly=True, ) - # Extend default field + # Extend default field for showing payment terms created by this module only. payment_term_id = fields.Many2one( "account.payment.term", domain=lambda self: [("id", "in", self._get_payment_terms())], diff --git a/utils/misc.py b/utils/misc.py index afc9e63..65d4482 100755 --- a/utils/misc.py +++ b/utils/misc.py @@ -23,13 +23,13 @@ from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_ class Utils(models.AbstractModel): _name = "client_contracts.utils" - @staticmethod + '''@staticmethod def parse_odoo_date(date: str): return dt.datetime.strptime(date, DEFAULT_SERVER_DATE_FORMAT) @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)''' @staticmethod def to_fixed(number, digit=2): diff --git a/views/res_partner.xml b/views/res_partner.xml index 016f0eb..c8613ec 100755 --- a/views/res_partner.xml +++ b/views/res_partner.xml @@ -20,7 +20,7 @@ res.partner.contract.info res.partner - + @@ -63,13 +63,11 @@ - - diff --git a/wizard/res_partner_contract_wizard.py b/wizard/res_partner_contract_wizard.py index 1f4ffe8..14ed4e4 100755 --- a/wizard/res_partner_contract_wizard.py +++ b/wizard/res_partner_contract_wizard.py @@ -17,8 +17,10 @@ class ContractWizard(models.TransientModel): # , Extension): _inherit = ["client_contracts.utils"] def _default_target(self): + _logger.debug("\n\n model: %s | id: %s \n\n", self.env.context.get("active_model"), self.env.context.get("self_id")) return "{model},{target_id}".format( - model=self.active_model, target_id=int(self.env.context.get("self_id")) + # model=self.active_model, target_id=int(self.env.context.get("self_id")) + model=self.env.context.get("active_model"), target_id=int(self.env.context.get("self_id")) ) def _default_document_template(self): @@ -177,7 +179,7 @@ class ContractWizard(models.TransientModel): # , Extension): .create( { "name": attachment_name, - "datas_fname": attachment_name, + "store_fname": attachment_name, "type": "binary", "datas": encoded_data, }