[IMP] rework res_partner model and dependencies of this
This commit is contained in:
parent
2cd8412cb0
commit
e0d4f43402
@ -257,7 +257,7 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_context_partner_contract_name(self):
|
||||
self._context_partner_contract_name = self.partner_id.contract_name
|
||||
self._context_partner_contract_name = self.partner_id.name
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_context_partner_adress(self):
|
||||
@ -265,11 +265,9 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_context_partner_representer_contract_name(self):
|
||||
# TODO: lite refactor
|
||||
partner_representer_contract_name = ''
|
||||
if self.partner_id.representative_id:
|
||||
partner_representer_contract_name = self.partner_id.representative_id.contract_name
|
||||
else:
|
||||
partner_representer_contract_name = ''
|
||||
partner_representer_contract_name = self.partner_id.representative_id.name
|
||||
self._context_partner_representer_contract_name = partner_representer_contract_name
|
||||
|
||||
@api.depends('partner_id')
|
||||
@ -302,7 +300,7 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
@api.depends('company_id')
|
||||
def _compute_context_seller_contract_name(self):
|
||||
self._context_seller_contract_name = self.company_id.contract_name
|
||||
self._context_seller_contract_name = self.company_id.name
|
||||
|
||||
@api.depends('company_id')
|
||||
def _compute_context_seller_adress(self):
|
||||
@ -310,20 +308,16 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
@api.depends('company_id')
|
||||
def _compute_context_seller_representer_contract_job_name(self):
|
||||
# TODO: lite refactor
|
||||
seller_represent_job_function = ''
|
||||
if self.company_id.representative_id:
|
||||
seller_represent_contract_job_name = self.company_id.representative_id.contract_job_name
|
||||
else:
|
||||
seller_represent_contract_job_name = ''
|
||||
self._context_seller_representer_contract_job_name = seller_represent_contract_job_name
|
||||
seller_represent_job_function = self.company_id.representative_id.function
|
||||
self._context_seller_representer_contract_job_name = seller_represent_job_function
|
||||
|
||||
@api.depends('company_id')
|
||||
def _compute_context_seller_representer_contract_name(self):
|
||||
# TODO: lite refactor
|
||||
seller_represent_contract_name = ''
|
||||
if self.company_id.representative_id:
|
||||
seller_represent_contract_name = self.company_id.representative_id.contract_name
|
||||
else:
|
||||
seller_represent_contract_name = ''
|
||||
seller_represent_contract_name = self.company_id.representative_id.name
|
||||
self._context_seller_representer_contract_name = seller_represent_contract_name
|
||||
|
||||
@api.depends('company_id')
|
||||
@ -418,7 +412,7 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _compute_partner_passport_data(self):
|
||||
return self.partner_id.passport_data
|
||||
return self.partner_id.passport_series + self.partner_id.passport_number
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _set_order_domain(self):
|
||||
@ -437,11 +431,11 @@ class ContractWizard(models.TransientModel):
|
||||
seller_represent_job_name = ''
|
||||
|
||||
if self.partner_id.representative_id:
|
||||
partner_representer_contract_name = self.partner_id.representative_id.contract_name
|
||||
partner_representer_contract_name = self.partner_id.representative_id.name
|
||||
|
||||
if self.company_id.representative_id:
|
||||
seller_represent_contract_name = self.company_id.representative_id.contract_name
|
||||
seller_represent_contract_job_name = self.company_id.representative_id.contract_job_name
|
||||
seller_represent_contract_name = self.company_id.representative_id.name
|
||||
seller_represent_contract_job_name = self.company_id.representative_id.function
|
||||
seller_represent_name = self.company_id.representative_id.name
|
||||
seller_represent_job_name = self.company_id.representative_id.function
|
||||
|
||||
@ -472,7 +466,7 @@ class ContractWizard(models.TransientModel):
|
||||
'name': self.contract_id.name,
|
||||
'current_date': contract_date.strftime('%d %b %Y'),
|
||||
|
||||
'partner_contract_name': self.partner_id.contract_name,
|
||||
'partner_contract_name': self.partner_id.name,
|
||||
'partner_adress': self.partner_id.full_adress,
|
||||
'partner_representer_contract_name': partner_representer_contract_name,
|
||||
'partner_inn': self.partner_id.inn,
|
||||
@ -480,11 +474,11 @@ class ContractWizard(models.TransientModel):
|
||||
'partner_rs': self.partner_id.bank_account.acc_number,
|
||||
'partner_bik': self.partner_id.bank_account.bank_id.bic,
|
||||
'partner_bank': self.partner_id.bank_account.bank_id.name,
|
||||
'partner_passport_data': self.partner_id.passport_data,
|
||||
'partner_passport_data': self.partner_id.passport_series + self.partner_id.passport_number,
|
||||
'partner_phone': self.partner_id.phone,
|
||||
'partner_representer_name': self.partner_id.representative_id.name,
|
||||
|
||||
'seller_contract_name': self.company_id.contract_name,
|
||||
'seller_contract_name': self.company_id.name,
|
||||
'seller_adress': self.company_id.full_adress,
|
||||
'seller_representer_contract_job_name': seller_represent_contract_job_name,
|
||||
'seller_representer_contract_name': seller_represent_contract_name,
|
||||
|
@ -18,20 +18,37 @@ class ResPartner(models.Model):
|
||||
compute='_compute_contract_count',
|
||||
string='# of contracts'
|
||||
)
|
||||
contract_job_name = fields.Char(
|
||||
string='Contract job name',
|
||||
help='Job position as it would be in contract'
|
||||
)
|
||||
contract_name = fields.Char(
|
||||
string='Contract name',
|
||||
help='Name, as it would be in contract'
|
||||
)
|
||||
# contract_job_name = fields.Char(
|
||||
# string='Contract job name',
|
||||
# help='Job position as it would be in contract'
|
||||
# ) # res.partner.function
|
||||
# contract_name = fields.Char(
|
||||
# string='Contract name',
|
||||
# help='Name, as it would be in contract'
|
||||
# ) # res.partner.name
|
||||
full_adress = fields.Char(
|
||||
compute='_compute_full_adress'
|
||||
) # Check for res.partner.contact_address in base/res
|
||||
address_actual = fields.Char(
|
||||
string='Actual Address',
|
||||
)
|
||||
passport_data = fields.Char(
|
||||
string='Passport',
|
||||
help='Passport data'
|
||||
passport_authority = fields.Char(
|
||||
string='Passport Authority',
|
||||
help='What Department issued the passport',
|
||||
)
|
||||
passport_date = fields.Date(
|
||||
string='Passport Issue Date',
|
||||
help='Date when receive a passport',
|
||||
)
|
||||
passport_number = fields.Char(
|
||||
string='Passport Number',
|
||||
)
|
||||
passport_series = fields.Char(
|
||||
string='Passport Series',
|
||||
)
|
||||
psrn = fields.Char(
|
||||
string='PSRN',
|
||||
help='Primary State Registration Number',
|
||||
)
|
||||
representative_id = fields.Many2one(
|
||||
'res.partner',
|
||||
@ -45,18 +62,20 @@ class ResPartner(models.Model):
|
||||
@api.one
|
||||
@api.depends('street', 'street2', 'city', 'state_id', 'zip', 'country_id')
|
||||
def _compute_full_adress(self):
|
||||
# TODO: lite rewrite
|
||||
address = ""
|
||||
full_street = "{} {}".format(
|
||||
self.street or "", self.street2 or "").strip()
|
||||
|
||||
if self.zip:
|
||||
full_adress = '{}, {}, {}, {} {}'.format(
|
||||
self.zip, self.country_id.name, self.city,
|
||||
self.street, self.street2
|
||||
)
|
||||
else:
|
||||
full_adress = '{}, {}, {} {}'.format(
|
||||
self.country_id.name, self.city,
|
||||
self.street, self.street2
|
||||
)
|
||||
self.full_adress = full_adress
|
||||
address += "{}, ".format(self.zip)
|
||||
|
||||
address += ", ".join(map(lambda el: el,
|
||||
(
|
||||
self.country_id.name or "",
|
||||
self.city or "",
|
||||
full_street or ""
|
||||
)))
|
||||
self.full_adress = address
|
||||
|
||||
@api.one
|
||||
@api.depends('self.client_contract_ids')
|
||||
|
@ -1,11 +1,11 @@
|
||||
from datetime import datetime
|
||||
import datetime
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class PartnerContract(models.Model):
|
||||
|
||||
_name = 'res.partner.contract'
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
name = fields.Char(
|
||||
string='Contract number',
|
||||
@ -14,7 +14,7 @@ class PartnerContract(models.Model):
|
||||
date = fields.Date(
|
||||
string='Date of conclusion',
|
||||
help='Date, when contract was concluded',
|
||||
default=datetime.now().date(),
|
||||
default=datetime.date.today(),
|
||||
required=True
|
||||
)
|
||||
order_ids = fields.One2many(
|
||||
|
@ -28,10 +28,9 @@
|
||||
<field name="model">res.partner.contract</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Contract">
|
||||
<header>
|
||||
<button name="do_toggle_active" type="object"
|
||||
string="Active" class="oe_highlight" />
|
||||
</header>
|
||||
<!-- <header>
|
||||
<button name="do_toggle_active" type="object" string="Active" class="oe_highlight" />
|
||||
</header> -->
|
||||
<sheet>
|
||||
<group string="Contract parameters" name="single_params">
|
||||
<field name="name" readonly="1"/>
|
||||
@ -90,10 +89,11 @@
|
||||
<field name="priority" eval="25"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='category_id']" position="after">
|
||||
<field name="contract_name"/>
|
||||
<field name="contract_job_name"/>
|
||||
<field name="name"/>
|
||||
<field name="function"/>
|
||||
<field name="representative_id" domain="[('id', 'in', child_ids)]" attrs="{'invisible': [('company_type', '!=', 'company')]}"/>
|
||||
<field name="passport_data" attrs="{'invisible': [('company_type', '=', 'company')]}"/>
|
||||
<field name="passport_series" attrs="{'invisible': [('company_type', '=', 'company')]}"/>
|
||||
<field name="passport_number" attrs="{'invisible': [('company_type', '=', 'company')]}"/>
|
||||
<field name="bank_account"/>
|
||||
<field name="signature" widget="image"/>
|
||||
</xpath>
|
||||
|
Loading…
x
Reference in New Issue
Block a user