Skip to content

Commit

Permalink
Merge PR #88 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by andhit-r
  • Loading branch information
ssi-bot committed Feb 23, 2025
2 parents fa5d650 + 7cc989b commit 5a2986c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ssi_service/models/service_contract_fix_item_payment_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def _get_fix_item_receivable_account(self):
def _prepare_invoice_data(self):
self.ensure_one()
contract = self.service_id
partner = contract.contact_partner_id or contract.partner_id
if contract.contractor_id:
partner = contract.contact_contractor_id or contract.contractor_id
else:
partner = contract.contact_id or contract.partner_id
journal = self._get_fix_item_receivable_journal()
self._get_fix_item_receivable_account()
lines = []
Expand Down
51 changes: 51 additions & 0 deletions ssi_service/models/service_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,37 @@ class ServiceMixin(models.AbstractModel):
],
},
)
allowed_contact_contractor_ids = fields.Many2many(
string="Allowed Contractor's Contact",
comodel_name="res.partner",
compute="_compute_allowed_contact_contractor_ids",
store=False,
)
contractor_id = fields.Many2one(
string="Contractor",
comodel_name="res.partner",
domain=[
("parent_id", "=", False),
],
required=False,
readonly=True,
states={
"draft": [
("readonly", False),
],
},
)
contact_contractor_id = fields.Many2one(
string="Contact's Contact",
comodel_name="res.partner",
required=False,
readonly=True,
states={
"draft": [
("readonly", False),
],
},
)
type_id = fields.Many2one(
string="Type",
comodel_name="service.type",
Expand Down Expand Up @@ -200,6 +231,26 @@ class ServiceMixin(models.AbstractModel):
copy=False,
)

@api.depends(
"contractor_id",
)
def _compute_allowed_contact_contractor_ids(self):
Partner = self.env["res.partner"]
for record in self:
result = []
if record.contractor_id:
criteria = [
("commercial_partner_id", "=", record.contractor_id.id),
("id", "!=", record.contractor_id.id),
("type", "=", "contact"),
]
result = Partner.search(criteria).ids
record.allowed_contact_contractor_ids = result

@api.onchange("contractor_id")
def onchange_contact_contractor_id(self):
self.contact_contractor_id = False

@api.depends("policy_template_id")
def _compute_policy(self):
_super = super(ServiceMixin, self)
Expand Down
23 changes: 23 additions & 0 deletions ssi_service/views/service_contract_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<data>
<xpath expr="//field[@name='company_id']" position="after">
<field name="partner_id" />
<field name="contractor_id" />
<field name="title" />
<field name="type_id" />
<field name="manager_id" />
Expand Down Expand Up @@ -39,6 +40,8 @@
<xpath expr="//field[@name='name']" position="after">
<field name="partner_id" />
<field name="contact_partner_id" />
<field name="contractor_id" />
<field name="contact_contractor_id" />
<field name="sale_team_id" />
<field name="salesperson_id" />
<field name="source_document_id" />
Expand All @@ -62,6 +65,16 @@
string="Contact"
context="{'group_by':'contact_partner_id'}"
/>
<filter
name="grp_contractor"
string="Contractor"
context="{'group_by':'contractor_id'}"
/>
<filter
name="grp_contact_contractor"
string="Contact's Contractor"
context="{'group_by':'contact_contractor_id'}"
/>
<filter
name="grp_sale_team"
string="Sale Team"
Expand Down Expand Up @@ -138,6 +151,16 @@
name="salesperson_id"
domain="[('id','in',allowed_salesperson_ids)]"
/>
<field name="contractor_id" />
<field
name="allowed_contact_contractor_ids"
widget="many2many_tags"
invisible="1"
/>
<field
name="contact_contractor_id"
domain="[('id','in',allowed_contact_contractor_ids)]"
/>
<field name="source_document_res_id" invisible="1" />
<field name="source_document_model_id" invisible="1" />
<field name="source_document_model" invisible="1" />
Expand Down
4 changes: 4 additions & 0 deletions ssi_service_quotation/models/service_quotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def _prepare_contract_data(self):
and self.contact_partner_id.id
or False,
"type_id": self.type_id.id,
"contractor_id": self.contractor_id and self.contractor_id.id or False,
"contact_contractor_id": self.contact_contractor_id
and self.contact_contractor_id.id
or False,
"user_id": self.user_id.id,
"manager_id": self.manager_id.id,
"company_id": self.company_id.id,
Expand Down
13 changes: 13 additions & 0 deletions ssi_service_quotation/views/service_quotation_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<data>
<xpath expr="//field[@name='company_id']" position="after">
<field name="partner_id" />
<field name="contractor_id" />
<field name="title" />
<field name="type_id" />
<field name="manager_id" />
Expand Down Expand Up @@ -39,6 +40,8 @@
<xpath expr="//field[@name='user_id']" position="after">
<field name="partner_id" />
<field name="contact_partner_id" />
<field name="contractor_id" />
<field name="contact_contractor_id" />
<field name="type_id" />
<field name="manager_id" />
<field name="currency_id" />
Expand Down Expand Up @@ -81,6 +84,16 @@
name="salesperson_id"
domain="[('id','in',allowed_salesperson_ids)]"
/>
<field name="contractor_id" />
<field
name="allowed_contact_contractor_ids"
widget="many2many_tags"
invisible="1"
/>
<field
name="contact_contractor_id"
domain="[('id','in',allowed_contact_contractor_ids)]"
/>
<separator string="Reference" colspan="2" />
<field name="source_document_res_id" invisible="1" />
<field name="source_document_model_id" invisible="1" />
Expand Down

0 comments on commit 5a2986c

Please sign in to comment.