[REM] l10n_latam_invoice_document: dynamic domains
Note: the original would only set the domain if `l10n_latam_use_documents` was enabled but even if the fields are not shown without that it doesn't make much sense to allow any document type to be selected when latam docs are *not* being used. In this revision, the document type is always filtered by available types and that is only non-empty if we're using latam documents. Task 2147923 closes odoo/odoo#40955 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -9,7 +9,8 @@ class AccountMoveReversal(models.TransientModel):
|
||||
_inherit = "account.move.reversal"
|
||||
|
||||
l10n_latam_use_documents = fields.Boolean(readonly=True)
|
||||
l10n_latam_document_type_id = fields.Many2one('l10n_latam.document.type', 'Document Type', ondelete='cascade')
|
||||
l10n_latam_document_type_id = fields.Many2one('l10n_latam.document.type', 'Document Type', ondelete='cascade', domain="[('id', 'in', l10n_latam_available_document_type_ids)]")
|
||||
l10n_latam_available_document_type_ids = fields.Many2many('l10n_latam.document.type', store=False)
|
||||
l10n_latam_sequence_id = fields.Many2one('ir.sequence', compute='_compute_l10n_latam_sequence')
|
||||
l10n_latam_document_number = fields.Char(string='Document Number')
|
||||
|
||||
@@ -47,8 +48,7 @@ class AccountMoveReversal(models.TransientModel):
|
||||
'company_id': self.move_ids.company_id.id,
|
||||
})
|
||||
self.l10n_latam_document_type_id = refund.l10n_latam_document_type_id
|
||||
return {'domain': {
|
||||
'l10n_latam_document_type_id': [('id', 'in', refund.l10n_latam_available_document_type_ids.ids)]}}
|
||||
self.l10n_latam_available_document_type_ids = refund.l10n_latam_available_document_type_ids
|
||||
|
||||
def reverse_moves(self):
|
||||
return super(AccountMoveReversal, self.with_context(
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<field name="l10n_latam_sequence_id" invisible="1"/>
|
||||
</form>
|
||||
<field name="date" position="before">
|
||||
<field name="l10n_latam_available_document_type_ids" invisible="1"/>
|
||||
<field name="l10n_latam_document_type_id" attrs="{'invisible': ['|', ('l10n_latam_use_documents', '=', False), ('refund_method', '=', 'refund')], 'required': [('l10n_latam_use_documents', '=', True), ('refund_method', '!=', 'refund')]}" options="{'no_open': True, 'no_create': True}"/>
|
||||
<field name="l10n_latam_document_number" attrs="{'invisible': ['|', ('l10n_latam_sequence_id', '!=', False), ('refund_method', '=', 'refund')], 'required': [('l10n_latam_sequence_id', '=', True), ('refund_method', '!=', 'refund')]}"/>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user