mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-19 16:02:04 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -24,7 +24,7 @@ class AccountDebitNote(models.TransientModel):
|
|||
"We won't copy them for debit notes from credit notes. ")
|
||||
# computed fields
|
||||
move_type = fields.Char(compute="_compute_from_moves")
|
||||
journal_type = fields.Char(compute="_compute_from_moves")
|
||||
journal_type = fields.Char(compute="_compute_journal_type")
|
||||
country_code = fields.Char(related='move_ids.company_id.country_id.code')
|
||||
|
||||
@api.model
|
||||
|
|
@ -33,6 +33,10 @@ class AccountDebitNote(models.TransientModel):
|
|||
move_ids = self.env['account.move'].browse(self.env.context['active_ids']) if self.env.context.get('active_model') == 'account.move' else self.env['account.move']
|
||||
if any(move.state != "posted" for move in move_ids):
|
||||
raise UserError(_('You can only debit posted moves.'))
|
||||
elif any(move.debit_origin_id for move in move_ids):
|
||||
raise UserError(_("You can't make a debit note for an invoice that is already linked to a debit note."))
|
||||
elif any(move.move_type not in ['out_invoice', 'in_invoice', 'out_refund', 'in_refund'] for move in move_ids):
|
||||
raise UserError(_("You can make a debit note only for a Customer Invoice, a Customer Credit Note, a Vendor Bill or a Vendor Credit Note."))
|
||||
res['move_ids'] = [(6, 0, move_ids.ids)]
|
||||
return res
|
||||
|
||||
|
|
@ -41,6 +45,10 @@ class AccountDebitNote(models.TransientModel):
|
|||
for record in self:
|
||||
move_ids = record.move_ids
|
||||
record.move_type = move_ids[0].move_type if len(move_ids) == 1 or not any(m.move_type != move_ids[0].move_type for m in move_ids) else False
|
||||
|
||||
@api.depends('move_type')
|
||||
def _compute_journal_type(self):
|
||||
for record in self:
|
||||
record.journal_type = record.move_type in ['in_refund', 'in_invoice'] and 'purchase' or 'sale'
|
||||
|
||||
def _prepare_default_values(self, move):
|
||||
|
|
@ -82,7 +90,7 @@ class AccountDebitNote(models.TransientModel):
|
|||
})
|
||||
else:
|
||||
action.update({
|
||||
'view_mode': 'tree,form',
|
||||
'view_mode': 'list,form',
|
||||
'domain': [('id', 'in', new_moves.ids)],
|
||||
})
|
||||
return action
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<group>
|
||||
<field name="reason"/>
|
||||
<field name="date" string="Debit Note Date"/>
|
||||
<field name="copy_lines" attrs="{'invisible': [('move_type', 'in', ['in_refund', 'out_refund'])]}"/>
|
||||
<field name="copy_lines" invisible="move_type in ['in_refund', 'out_refund']"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="journal_id" domain="[('type', '=', journal_type)]"/>
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
</group>
|
||||
<footer>
|
||||
<button string='Create Debit Note' name="create_debit" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>
|
||||
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="x"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
|
@ -30,11 +30,11 @@
|
|||
<record id="action_view_account_move_debit" model="ir.actions.act_window">
|
||||
<field name="name">Create Debit Note</field>
|
||||
<field name="res_model">account.debit.note</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_mode">list,form</field>
|
||||
<field name="view_id" ref="view_account_debit_note"/>
|
||||
<field name="target">new</field>
|
||||
<field name="binding_model_id" ref="account.model_account_move" />
|
||||
<field name="binding_view_types">list</field>
|
||||
<field name="binding_view_types">list,kanban</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue