counterpart_journal_id workflow in wizard

16.0
Florian Roger 1 month ago
parent 293945d726
commit 8636392a40

@ -12,27 +12,17 @@ class AccountJournal(models.Model):
for journal in self:
journal.ensure_one()
# # Add default lines
# cash_units = self.env["cash.unit"].search(
# [
# ("auto_create", "in", ("both", 'deposit')),
# ("currency_id", "=", deposit.currency_id.id),
# ]
# )
# deposit.line_ids = [(0, 0, {
# "cash_unit_id": cunit.id,
# "qty": 0,
# "currency_id": deposit.currency_id.id}) for cunit in cash_units ]
# Call form view
action = self.env['ir.actions.act_window']._for_xml_id('gn_cash.account_cash_inorout_action_wizard')
action['context'] = {
ctx = dict(self.env.context)
ctx.update({
'default_company_id': self.env.company.id,
'default_currency_id': journal.currency_id.id or journal.company_currency_id.id,
'default_operating_journal_id': journal.id,
'default_step': 'type',
}
})
action['context'] = ctx
return action

@ -128,7 +128,8 @@ class AccountCashDepositWizard(models.TransientModel):
def action_confirm(self):
total_amount = self.total_amount if self.total_amount > 0 else False
if self.operation_type and self.has_partner and total_amount:
if self.operation_type and total_amount and self.has_partner \
and not (self.has_partner == 'bktobk' and not self.counterpart_journal_id):
if self.operation_type == 'order':
self.order_date = self.order_date if self.order_date else self.date if self.date else fields.Date.context_today(self)
self.date = False
@ -153,12 +154,19 @@ class AccountCashDepositWizard(models.TransientModel):
else:
self.deposit_id.update(deposit_values)
else:
raise ValidationError("Some fields require your attention: %s" % ' and '.join([
field[0] for field in [
fields = [
("Type d'opération", self.operation_type),
("Choix du partenaire", self.has_partner),
("Choix du partenaire", self.has_partner),
("Montant total",total_amount)
] if not field[1]
]
if self.operation_type and self.has_partner:
if self.has_partner == 'bktobk' and not self.counterpart_journal_id:
if self.operation_type == 'order':
fields.append(("Banque ou caisse de destination", self.counterpart_journal_id))
else:
fields.append(("Banque ou caisse d'origine'", self.counterpart_journal_id))
raise ValidationError("Some fields require your attention: %s" % ' and '.join([
field[0] for field in fields if not field[1]
]))
_logger.warning("deposit %s created/updated" % self.deposit_id.id)
return {

@ -13,6 +13,9 @@
<field name="step" widget="statusbar" options="{'clickable': True}"/>
</header>
<group>
<field name="operating_journal_id" string="Compte de destination" readonly='1' attrs="{'invisible': [('operation_type', '!=', 'deposit')]}"/>
<field name="operating_journal_id" string="Compte de provenance" readonly='1' attrs="{'invisible': [('operation_type', '!=', 'order')]}"/>
<field name="operating_journal_id" string="Compte" readonly='1' attrs="{'invisible': [('operation_type', 'in', ['order', 'deposit'])]}"/>
<!-- Invisible fields-->
<field name="company_id" invisible='1'/>
<field name="currency_id" invisible='1'/>
@ -24,9 +27,11 @@
<group name="Type of Partner" id="partner_type_choice">
<field name="has_partner"/>
</group>
<group name="Account of Partner" id="partner_account_choice">
<field name="bank_journal_id" attrs="{'invisible': [('has_partner', '!=', 'bktobk')]}"/>
<field name="partner_id" attrs="{'invisible': [('has_partner', '!=', 'other')]}"/>
<group name="Account of Partner" id="partner_account_choice" attrs="{'invisible': [('has_partner', '!=', 'other')]}">
<field name="partner_id" domain="[('id', '!=', context.get('uid'))]"/>
</group>
<group name="Counterpart Journal" id="counterpart_journal_choice" attrs="{'invisible': [('has_partner', '!=', 'bktobk')]}">
<field name="counterpart_journal_id" domain="[('type', 'in', ['bank', 'cash']), ('id','!=', context.get('default_operating_journal_id'))]"/>
</group>
</group>
<group name="Main Content" id="content" attrs="{'invisible': [('step', '!=', 'content')]}">

Loading…
Cancel
Save