[ENH] delivery_carrier_partner_account: company_id + view all from menu
Add the ability to view all the transporter accounts from the sales configuration menu. Add company_id to delivery.carrier.account model as a related field to delivery.carrier. Also constrain the delivery.carrier and res.partner associated to an account to be linked to the same company. Fixes #113
This commit is contained in:
parent
b6eca04802
commit
01c424c485
4 changed files with 43 additions and 3 deletions
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
{
|
||||
"name": "Carrier Accounts by Partner",
|
||||
"version": "17.0.0.1.0",
|
||||
"version": "17.0.0.1.1",
|
||||
"summary": "Add one or many carrier accounts per partner",
|
||||
"category": "Delivery",
|
||||
"author": "Bemade Inc.",
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"security/record_rules.xml",
|
||||
"data/actions.xml",
|
||||
"views/res_partner_views.xml",
|
||||
"views/delivery_carrier_views.xml",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,19 @@
|
|||
<field name="view_mode">tree,form</field>
|
||||
<field name="target">current</field>
|
||||
<field name="domain">[('delivery_carrier_id', '=', context.get("carrier_id"))]</field>
|
||||
<field name="context">{'default_delivery_carrier_id': active_id}</field>
|
||||
<field name="context">{'default_delivery_carrier_id': "active_id"}</field>
|
||||
</record>
|
||||
<record id="action_open_all_delivery_carrier_accounts" model="ir.actions.act_window">
|
||||
<field name="name">Carrier Accounts</field>
|
||||
<field name="res_model">delivery.carrier.account</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="target">current</field>
|
||||
</record>
|
||||
<menuitem id="delivery_carrier_accounts"
|
||||
parent="sale.menu_sales_config"
|
||||
sequence="30"
|
||||
action="delivery_carrier_partner_account.action_open_all_delivery_carrier_accounts"
|
||||
name="Carrier Accounts"
|
||||
/>
|
||||
/>
|
||||
</odoo>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from odoo import models, fields, api
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class DeliveryCarrierAccount(models.Model):
|
||||
|
|
@ -24,7 +25,18 @@ class DeliveryCarrierAccount(models.Model):
|
|||
ondelete="cascade",
|
||||
)
|
||||
|
||||
company_id = fields.Many2one(
|
||||
comodel_name="res.company",
|
||||
related="delivery_carrier_id.company_id",
|
||||
)
|
||||
|
||||
@api.depends("account_number")
|
||||
def _compute_display_name(self):
|
||||
for record in self:
|
||||
record.display_name = record.account_number
|
||||
|
||||
@api.constrains("partner_id", "delivery_carrier_id")
|
||||
def _constrain_partner_carrier_same_company(self):
|
||||
for rec in self:
|
||||
if rec.partner_id.company_id != rec.delivery_carrier_id.company_id:
|
||||
raise UserError(_("Partner and Carrier must be in the same company."))
|
||||
|
|
|
|||
14
delivery_carrier_partner_account/security/record_rules.xml
Normal file
14
delivery_carrier_partner_account/security/record_rules.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="rule_delivery_carrier_account" model="ir.rule">
|
||||
<field name="name">Multi-company rule for Delivery Carrier Account</field>
|
||||
<field name="model_id" ref="model_delivery_carrier_account"/>
|
||||
<field name="domain_force">[
|
||||
('company_id', 'in', company_ids + [False])]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
|
||||
<field name="perm_read" eval="True"/>
|
||||
<field name="perm_write" eval="True"/>
|
||||
<field name="perm_unlink" eval="True"/>
|
||||
<field name="perm_create" eval="True"/>
|
||||
</record>
|
||||
</odoo>
|
||||
Loading…
Reference in a new issue