Hii,

 Iam trying to create an invoice and save it, but later i realized that 
each line in an invoice should be saved in order to save the 
account.invoice,

*hence i tried this code*

Invoice = Model.get('account.invoice')
    InvoiceLine = Model.get('account.invoice.line')
    invoice = Invoice()
    invoice.party = party
    invoice.payment_term = payment_term
    line = invoice.lines.new()
    line.product = product
    line.quantity = 5


    account=create_account(company,'revenue','Main Income')
    account.type=creat_types(company)
    account.save()
    # pdb.set_trace()
    line.account=account#<<----line of error
    line.save()
    invoice.lines.append(line)



*but this lead me to this error:*

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(
fname, *where)
    176             else:
    177                 filename = fname
--> 178             __builtin__.execfile(filename, *where)


/home/projects/tutorials/invoice_testing.py in <module>()
    120     account.save()
    121     # pdb.set_trace()
--> 122     line.account=account#<<----line of error
    123     line.save()
    124     invoice.lines.append(line)


/home/projects/tutorials/lib/python2.7/site-packages/proteus/__init__.pyc in 
__set__(self, instance, value)
    258         if value:
    259             assert value._config == instance._config
--> 260         super(Many2OneDescriptor, self).__set__(instance, value)
    261 
    262 


/home/projects/tutorials/lib/python2.7/site-packages/proteus/__init__.pyc in 
__set__(self, instance, value)
    127         if previous != getattr(instance, self.name):
    128             instance._changed.add(self.name)
--> 129             instance._on_change([self.name])
    130             if instance._parent:
    131                 instance._parent._changed.add(instance.
_parent_field_name)


/home/projects/tutorials/lib/python2.7/site-packages/proteus/__init__.pyc in 
_on_change(self, names)
   1000         if values:
   1001             context = self._config.context
-> 1002             changes = getattr(self._proxy, 'on_change')(values, 
names, context)
   1003             for change in changes:
   1004                 self._set_on_change(change)


/home/projects/tutorials/lib/python2.7/site-packages/proteus/config.pyc in 
__call__(self, *args)
    176                 inst = args.pop(0)
    177                 if hasattr(inst, self._name):
--> 178                     result = rpc.result(meth(inst, *args, **kwargs))
    179                 else:
    180                     result = [rpc.result(meth(i, *args, **kwargs))


/home/projects/tutorials/FSERP/trytond/trytond/model/modelview.pyc in 
on_change(self, fieldnames)
    654             method = getattr(self, 'on_change_%s' % fieldname, None)
    655             if method:
--> 656                 method()
    657         # XXX remove backward compatibility
    658         return [self._changed_values]


/home/projects/tutorials/FSERP/trytond/trytond/model/modelview.pyc in 
wrapper(self, *args, **kwargs)
     80     def wrapper(self, *args, **kwargs):
     81         result = func(self, *args, **kwargs)
---> 82         assert result is None, func
     83         return self
     84     wrapper.on_change = True


AssertionError: <unbound method account.invoice.line.on_change_account>



---------------------------------------------
Since iam running the script in ipython i tried to check what is the value 
of line.account, it shows the correct account as assigned in the code at 
which the error occurred.
so why did the error occur in the first place?
and after it quits with an error in interpretter after checking the value 
of line.account(which was assigned properly) i tried to append it to the 
invoice using invoice.lines.append(line),
*but it showed me this error:*
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-13-09f033319b02> in <module>()
----> 1 invoice.lines.append(line)


/home/projects/tutorials/lib/python2.7/site-packages/proteus/__init__.pyc in 
append(self, record)
    549 
    550     def append(self, record):
--> 551         self.__check([record])
    552         res = super(ModelList, self).append(record)
    553         self._changed()


/home/projects/tutorials/lib/python2.7/site-packages/proteus/__init__.pyc in 
__check(self, records)
    535                 config = record._config
    536         for record in records:
--> 537             assert record._parent is None
    538             assert not record._parent_field_name
    539             assert not record._parent_name


AssertionError: 

---------------------------------------------------

i think i am missing something important

trytond v3.6.0
proteus v3.6.0
standard modules v3.6.0

help
regards
Jitesh

Reply via email to