Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][IMP] Add some feature in account_operating_unit module #740

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions account_operating_unit/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,19 @@ def _check_journal_operating_unit(self):
_("The OU in the Move and in Journal must be the same.")
)
return True

@api.constrains("operating_unit_id", "company_id")
def _check_company_operating_unit(self):
for move in self:
if (
move.company_id
and move.operating_unit_id
and move.company_id != move.operating_unit_id.company_id
):
raise UserError(
_(
"The Company in the Move and in "
"Operating Unit must be the same."
)
)
return True
94 changes: 82 additions & 12 deletions account_operating_unit/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,36 @@
groups="operating_unit.group_multi_operating_unit"
readonly="state != 'draft'"
/>
<field
name="operating_unit_id"
invisible="1"
groups="!operating_unit.group_multi_operating_unit"
readonly="state != 'draft'"
/>
</xpath>
</field>
<field name="invoice_line_ids" position="attributes">
<attribute name="context" operation="update">
{
'operating_unit_id': operating_unit_id,
'default_operating_unit_id': operating_unit_id
}
<attribute
name="context"
>{'default_type': context.get('default_type'), 'journal_id': journal_id, 'default_partner_id': commercial_partner_id, 'default_currency_id': currency_id != company_currency_id and currency_id or False, 'operating_unit_id': operating_unit_id}</attribute>
</field>
<xpath
expr="//field[@name='invoice_line_ids']/tree/field[@name='analytic_account_id']"
position="attributes"
>
<attribute
name="domain"
>['|', ('company_id', '=', False), ('company_id', '=', parent.company_id), '|', ('operating_unit_ids', '=', context.get('operating_unit_id', False)), ('operating_unit_ids', '=', False)]</attribute>
</xpath>
<xpath
expr="//field[@name='invoice_line_ids']/form/sheet/group/field[@name='analytic_account_id']"
position="attributes"
>
<attribute
name="domain"
>['|', ('operating_unit_ids', '=', context.get('operating_unit_id', False)), ('operating_unit_ids', '=', False)]</attribute>
</xpath>
<field name="line_ids" position="attributes">
<attribute name="context">{
'default_type': context.get('default_type'),
'line_ids': line_ids,
'journal_id': journal_id,
'default_partner_id': commercial_partner_id,
'default_currency_id': currency_id != company_currency_id and currency_id or False,
'default_operating_unit_id': operating_unit_id}
</attribute>
</field>
<field name="line_ids" position="attributes">
Expand Down Expand Up @@ -115,6 +132,59 @@
groups="operating_unit.group_multi_operating_unit"
/>
</xpath>
<xpath
expr="//field[@name='line_ids']/tree/field[@name='analytic_account_id']"
position="attributes"
>
<attribute
name="domain"
>['|', ('company_id', '=', parent.company_id), ('company_id', '=', False), '|', ('operating_unit_ids', '=', context.get('default_operating_unit_id', False)), ('operating_unit_ids', '=', False)]</attribute>
</xpath>
<xpath
expr="//field[@name='line_ids']/form/group/field[@name='analytic_account_id']"
position="attributes"
>
<attribute
name="domain"
>['|', ('operating_unit_ids', '=', context.get('default_operating_unit_id', False)), ('operating_unit_ids', '=', False)]</attribute>
</xpath>
</field>
</record>
<record id="view_invoice_tree" model="ir.ui.view">
<field name="name">account.invoice.tree</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_invoice_tree" />
<field name="arch" type="xml">
<field name="company_id" position="before">
<field
name="operating_unit_id"
options="{'no_create': True}"
groups="operating_unit.group_multi_operating_unit"
/>
</field>
</field>
</record>
<record id="view_account_invoice_filter" model="ir.ui.view">
<field name="name">account.invoice.select</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_invoice_filter" />
<field name="arch" type="xml">
<field name="invoice_user_id" position="after">
<field
name="operating_unit_id"
groups="operating_unit.group_multi_operating_unit"
/>
</field>
<filter name="salesperson" position="after">
<filter
string="Operating Unit"
name="operating_unit_grouped"
icon="terp-folder-orange"
domain="[]"
groups="operating_unit.group_multi_operating_unit"
context="{'group_by':'operating_unit_id'}"
/>
</filter>
</field>
</record>
<record id="view_invoice_tree" model="ir.ui.view">
Expand Down
Loading