Offer print form seems ready
This commit is contained in:
parent
a3b8741632
commit
20e7dc02de
@ -337,7 +337,7 @@ partner = self.partner_id
|
||||
|
||||
# Functions
|
||||
_ = self._t
|
||||
# get_date = self.contract_id.get_date
|
||||
to_fixed = self.env["client_contracts.utils"].to_fixed
|
||||
|
||||
# Parse date
|
||||
months = ["",
|
||||
@ -355,8 +355,6 @@ MM = months[mm]
|
||||
dd = dd if dd // 10 else '0{}'.format(dd)
|
||||
mm = mm if mm // 10 else '0{}'.format(mm)
|
||||
|
||||
# order_date = self.order_id.date_order
|
||||
|
||||
# ctx keys must be declared in this xml with id equal to "contract_field_{technical_name}"
|
||||
ctx = {
|
||||
# For manual filling on offer creation
|
||||
@ -368,20 +366,13 @@ ctx = {
|
||||
"offer_name": self.name,
|
||||
"offer_date": "{} {} {}".format(offer_date.day, months[offer_date.month], offer_date.year),
|
||||
|
||||
# "delivery_address": self.delivery_address,
|
||||
"commitment_date": self.commitment_date,
|
||||
# "products_amount": len(self.order_line.filtered(lambda rec: not rec.display_type)),
|
||||
"amount_untaxed": self.amount_untaxed,
|
||||
"amount_tax": self.amount_tax,
|
||||
"amount_total": self.amount_total,
|
||||
"amount_untaxed": to_fixed(self.amount_untaxed),
|
||||
"amount_tax": to_fixed(self.amount_tax),
|
||||
"amount_total": to_fixed(self.amount_total),
|
||||
"currency_symbol": self.currency_id.symbol,
|
||||
"terms_and_conditions": self.note,
|
||||
|
||||
# "payment_part_one": self.payment_part_one,
|
||||
# "payment_part_two": self.payment_part_two,
|
||||
# "payment_part_three": self.payment_part_three,
|
||||
# "delivery_period": self.delivery_period,
|
||||
|
||||
"dd": dd,
|
||||
"mm": mm,
|
||||
"MM": MM,
|
||||
@ -390,11 +381,6 @@ ctx = {
|
||||
|
||||
"seller_name": seller.name_write,
|
||||
"seller_company_form": _(dict(seller._fields['company_form'].selection).get(seller.company_form)),
|
||||
# "seller_representer_name": seller.representative_id.name,
|
||||
# "seller_representer_name_parent": seller.representative_id.name_genitive,
|
||||
# "seller_representer_name_initials": seller.representative_id.name_initials,
|
||||
# "seller_representer_function": seller.representative_id.function,
|
||||
# "seller_representer_function_parent": seller.representative_id.function_genitive,
|
||||
|
||||
"seller_inn": seller.vat,
|
||||
"seller_kpp": seller.iec,
|
||||
@ -402,14 +388,6 @@ ctx = {
|
||||
"seller_business_address": seller.full_address,
|
||||
"seller_phone": seller.phone,
|
||||
"seller_email": seller.email,
|
||||
|
||||
"partner_name": partner.name_write,
|
||||
"partner_representer_name": partner.representative_id.name,
|
||||
"partner_representer_name_initials": partner.representative_id.name_initials,
|
||||
"partner_inn": partner.vat,
|
||||
"partner_business_address": partner.full_address,
|
||||
"partner_phone": partner.phone,
|
||||
"partner_email": partner.email,
|
||||
}
|
||||
|
||||
seller_bank = seller.bank_ids and seller.bank_ids[0]
|
||||
@ -427,68 +405,10 @@ if seller_bank:
|
||||
"seller_bic": bank.bic,
|
||||
})
|
||||
|
||||
partner_bank = partner.bank_ids and partner.bank_ids[0]
|
||||
if partner_bank:
|
||||
|
||||
bank = partner_bank.bank_id
|
||||
bank_name = bank and bank.name or ""
|
||||
bank_city = "г. {city}".format(city=bank.city) if bank and bank.city else ""
|
||||
partner_bank_name = "{} {}".format(bank_name, bank_city).strip()
|
||||
|
||||
ctx.update({
|
||||
"partner_bank": partner_bank_name,
|
||||
"partner_rs": partner_bank.acc_number,
|
||||
"partner_ks": bank.corr_account,
|
||||
"partner_bic": bank.bic,
|
||||
})
|
||||
|
||||
|
||||
# Person
|
||||
if not partner.is_company:
|
||||
ctx.update({
|
||||
# "partner_representer_name": partner.name_write,
|
||||
# "partner_representer_name_initials": partner.name_initials,
|
||||
# "partner_representer_passport_number": partner.passport_number,
|
||||
# "partner_representer_passport_date": partner.passport_date,
|
||||
# "partner_representer_passport_department": partner.passport_department,
|
||||
})
|
||||
if not partner.name_write:
|
||||
ctx.update({
|
||||
"partner_name": partner.name,
|
||||
# "partner_representer_name": partner.name,
|
||||
})
|
||||
else:
|
||||
# Company
|
||||
ctx.update({
|
||||
"partner_company_form": _(dict(partner._fields['company_form'].selection).get(partner.company_form)),
|
||||
# "partner_representer_name_parent": partner.representative_id.name_genitive,
|
||||
# "partner_representer_document_parent": partner.representative_document,
|
||||
# "partner_representer_function": partner.representative_id.function,
|
||||
# "partner_representer_function_parent": partner.representative_id.function_genitive,
|
||||
})
|
||||
|
||||
if partner.company_form == 'sp':
|
||||
# Sole Proprietor
|
||||
ctx.update({
|
||||
"partner_ip_number": partner.sp_register_number,
|
||||
"partner_ip_date": partner.sp_register_date,
|
||||
"partner_ogrnip": partner.psrn_sp,
|
||||
# "partner_representer_passport_number": partner.representative_id.passport_number,
|
||||
# "partner_representer_passport_date": partner.representative_id.passport_date,
|
||||
# "partner_representer_passport_department": partner.representative_id.passport_department,
|
||||
})
|
||||
if partner.company_form == 'plc':
|
||||
# Private Limited Company
|
||||
ctx.update({
|
||||
"partner_kpp": partner.iec,
|
||||
"partner_ogrn": partner.psrn,
|
||||
})
|
||||
|
||||
action = ctx
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Functions -->
|
||||
|
||||
<record id="contract_field_number2words" model="res.partner.contract.field">
|
||||
|
@ -87,3 +87,9 @@ class SaleOrder(models.Model):
|
||||
arg {str} -- String to translate
|
||||
"""
|
||||
return _(arg)
|
||||
|
||||
@staticmethod
|
||||
def to_fixed(number, digit=2):
|
||||
if isinstance(number, str) and number.isdigit():
|
||||
number = float(number)
|
||||
return f"{number:.{digit}f}"
|
||||
|
@ -1,38 +1,11 @@
|
||||
import datetime as dt
|
||||
|
||||
# import inspect
|
||||
|
||||
from odoo import models # , fields
|
||||
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
||||
|
||||
'''class IDocument(object):
|
||||
"""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):
|
||||
raise NotImplementedError(
|
||||
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
||||
)
|
||||
|
||||
def get_filename_by_document_template(self, document_template_id: fields.Many2one):
|
||||
raise NotImplementedError(
|
||||
"Method {} is not implemented".format(inspect.currentframe().f_code.co_name)
|
||||
)'''
|
||||
from odoo import models
|
||||
|
||||
|
||||
class Utils(models.AbstractModel):
|
||||
_name = "client_contracts.utils"
|
||||
|
||||
"""@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)"""
|
||||
|
||||
@staticmethod
|
||||
def to_fixed(number, digit=2):
|
||||
if isinstance(number, str) and number.isdigit():
|
||||
number = float(number)
|
||||
return format(number, ".{digit}f".format(digit=digit))
|
||||
return f"{number:.{digit}f}"
|
||||
|
@ -239,8 +239,8 @@ class ContractWizard(models.TransientModel):
|
||||
"label": group_description,
|
||||
"count": 1.0,
|
||||
"unit": self.env.ref("uom.product_uom_unit").name,
|
||||
"cost_wo_vat": group_amount,
|
||||
"subtotal": group_amount,
|
||||
"cost_wo_vat": self.to_fixed(group_amount),
|
||||
"subtotal": self.to_fixed(group_amount),
|
||||
"display_type": False,
|
||||
}
|
||||
)
|
||||
@ -255,14 +255,13 @@ class ContractWizard(models.TransientModel):
|
||||
item.display_type == "line_note"
|
||||
or item.display_type == "line_section"
|
||||
and item.name.find("--fold") == -1
|
||||
or not folded_group
|
||||
and not item.display_type
|
||||
):
|
||||
or not item.display_type
|
||||
) and not folded_group:
|
||||
lines_data.append(
|
||||
{
|
||||
"number": next(counter) if not item.display_type else "",
|
||||
"vendor_code": item.product_id.default_code
|
||||
if item.product_id
|
||||
if (item.product_id and item.product_id.default_code)
|
||||
else "",
|
||||
"label": item.product_id.display_name
|
||||
if item.product_id
|
||||
@ -270,14 +269,14 @@ class ContractWizard(models.TransientModel):
|
||||
"description": item.name,
|
||||
"count": item.product_uom_qty,
|
||||
"unit": item.product_uom.name if item.product_uom else "",
|
||||
"cost": item.price_unit,
|
||||
"cost_wo_vat": item.price_reduce_taxexcl,
|
||||
"cost": self.to_fixed(item.price_unit),
|
||||
"cost_wo_vat": self.to_fixed(item.price_reduce_taxexcl),
|
||||
"discount": item.discount,
|
||||
"subtotal": item.price_subtotal,
|
||||
"subtotal": self.to_fixed(item.price_subtotal),
|
||||
"display_type": item.display_type,
|
||||
}
|
||||
)
|
||||
# Line with product inside folded group #
|
||||
# Line with product or comment inside folded group #
|
||||
if folded_group and not item.display_type:
|
||||
group_amount += item.price_subtotal
|
||||
# Last folded group handling #
|
||||
@ -287,10 +286,10 @@ class ContractWizard(models.TransientModel):
|
||||
"number": next(counter),
|
||||
"vendor_code": "",
|
||||
"label": group_description,
|
||||
"count": 1,
|
||||
"count": 1.0,
|
||||
"unit": self.env.ref("uom.product_uom_unit").name,
|
||||
"cost_wo_vat": group_amount,
|
||||
"subtotal": group_amount,
|
||||
"cost_wo_vat": self.to_fixed(group_amount),
|
||||
"subtotal": self.to_fixed(group_amount),
|
||||
"display_type": False,
|
||||
}
|
||||
)
|
||||
|
BIN
Шаблон_КП.docx
BIN
Шаблон_КП.docx
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user