se adiciona __setup__ para inicializar modelos

FossilOrigin-Name: 504ad84bee1c708c2b55fdde3552d39980bf1efad3a51de8050018e4d1f387f3
This commit is contained in:
bit4bit
2021-07-09 01:03:51 +00:00
parent b3e4a088b7
commit a1a9746353
4 changed files with 37 additions and 10 deletions

View File

@@ -506,3 +506,15 @@ def test_field_amount():
assert '<Line amount="33"/>' == line.to_xml()
def test_model_setup():
class Line(facho.model.Model):
__name__ = 'Line'
amount = fields.Attribute(name='amount')
def __setup__(self):
self.amount = 23
line = Line()
assert '<Line amount="23"/>' == line.to_xml()

View File

@@ -36,5 +36,8 @@ def _test_simple_invoice_cufe():
line = invoice.lines.create()
line.quantity = 1
line.price = 1_500_000
subtotal = line.taxtotal.subtotals.create()
subtotal.percent = 19.0
line_subtotal = line.taxtotal.subtotals.create()
line_subtotal.percent = 19.0
line.subtotal.scheme = '01'
assert invoice.cufe == '8bb918b19ba22a694f1da11c643b5e9de39adf60311cf179179e9b33381030bcd4c3c3f156c506ed5908f9276f5bd9b4'