IRC logs of #tryton for Friday, 2014-05-02 #tryton log beginning Fri May 2 00:00:01 CEST 2014
alisonken1lap3server would be trytond - client would be tryton00:27
alisonken1lap3ephase: ^^00:27
-!- ephase( has joined #tryton00:40
-!- meanmicio( has joined #tryton01:32
-!- meanmicio(~lfm@fsf/member/meanmicio) has joined #tryton01:32
-!- frispete( has joined #tryton06:40
-!- yangoon1( has joined #tryton07:02
-!- mar( has joined #tryton07:34
-!- sharoonthomas(~sharoonth@ has joined #tryton08:08
-!- pobsteta(~Thunderbi@ has joined #tryton08:23
-!- sharoonthomas_(~sharoonth@ has joined #tryton08:24
-!- mar( has joined #tryton08:43
-!- jeancavallo( has joined #tryton08:47
-!- mar( has joined #tryton09:10
marAttributeError: 'account.invoice' Model has no attribute 'state': {'currency': Pool().get('currency.currency')(1)}09:20
marwhy do I get this error, invoice definately has "state"09:20
marI'm doing:
-!- mar( has joined #tryton09:42
pokolimar: which version you are?09:43
marwhat I am trying to do is to add new functionality into InvoiceLine09:45
marI have relation InvoiceLine -> many LineMove objects09:45
marI define it as:     line_moves = fields.One2Many('trytonlt.line_move', 'invoice_line', 'Line moves', on_change_with=['quantity'])09:45
marand on quantity change I want to update objects in that relation09:46
maro I define:     def on_change_with_line_moves(self):09:46
pokolimar: I'm not sure, but maybe self.invoice is the id of the invoice and not the object?09:47
marself.invoice is account.invoice,None09:47
marand it seems that it not "initialized" with default values, etc09:47
marmaybe it's some proteus thing again?09:48
pokolimar: sure :)09:48
pokolimar: it sound like the same problem than yesterday :P09:48
marit's the same testcase ;)09:48
-!- sharoonthomas(~sharoonth@ has joined #tryton09:49
maryesterdays problem was what I accessed invoice line directly, not from invoice09:51
-!- nicoe(~nicoe@2001:6f8:3aa:0:b699:baff:fe56:2328) has joined #tryton09:51
pokolimar: I can not see anything wrong :S09:52
mardoes my on_change_with sound correct?09:53
pokolimar: in my eyes yes09:54
pokolimar: have you tested it from the tryton client?09:54
marwhat does my on_change_with_line_moves should return?09:55
marself.line_moves ?09:55
pokolimar: the value of the line_moves field you want09:55
marso line_moves is relation, so I should return [] or something, right?09:56
pokolimar: it's a One2Many, so a list of values to create/update/remove09:56
marso basically     def on_change_with_line_moves(self):09:57
mar        return self.line_moves09:57
marshould work, right?09:57
pokolimar: no09:58
pokoliI'm tryton to find and example no core modules09:59
pokolimar: basically a dict, where the keys are the operations (add, update, remove, delete) and depending on the key you return a diferent value10:01
mar{'relation_column': dict(keys=(add,update..))}10:02
marso if I want no changes:     def on_change_with_line_moves(self):10:02
mar        return {}10:02
pokolimar: for remove you return the ids to remove, for add a list of values to add, for update the [ids], and the values to write10:02
pokolimar: the example is an on_change, you're on on_change_with so you must return the dict directly10:03
marso if I want to update some line_move I do10:03
mar{line_moves: {id: {update_key: update_value}}?10:04
pokolimar: [('write', ([ids]: {update_key: update_value}))]10:06
pokolimar: but I'm wondering if it's not easier to do it on invoice posting10:07
marso do I need to specify column?10:12
marreturn {'line_moves': changes_dict}10:15
marchanges_dict.keys() == ['add', 'remove', ...]10:16
marchanges_dict['write'] = [ ('id', {key: value}),  ]10:16
marand how do I check if object is "saved"? is not None?10:17
-!- sharkcz( has joined #tryton10:24
marI still don't get it10:32
mar        print invoice_line10:32
mar        invoice_line.quantity = Decimal('12.')10:32
mardef on_change_with_line_moves(self):10:32
mar        print self10:32
maroutput is:10:32
marwhy on_change_with_move_lines == None?10:32
-!- udono1( has joined #tryton10:34
marpokoli, ?10:36
-!- lfm( has joined #tryton10:37
pokolimar: no column because you are using on_change_with10:37
pokoliACTION is reading all the comments 10:38
pokolimar: don't understand why you need to save10:39
mari don't need to save it10:41
marI need to check current line_moves and change those according to change in quantity10:42
marand self.line_moves is not existing :/10:42
-!- yangoon( has joined #tryton10:45
pokolimar: and what do you have to change?10:45
marself.line_move[0].quantity = self.quantity10:46
marfor example10:46
-!- uranus( has joined #tryton10:53
pokolijust return {'write', ([line_move[0].id], {'quantity': self.quantity})}11:01
marbut self.line_moves is non existant :/11:06
marAttributeError: 'account.invoice.line' Model has no attribute 'line_moves': {'currency': Pool().get('currency.currency')(1), 'type': u'line', 'invoice': Pool().get('account.invoice')(**{'currency': 1}), 'unit_price': Decimal('5000.0000'), 'quantity': 12.0}11:07
marany ideas, pokoli?11:15
pokolimar: can you explain why you need to change line_moves in on_change?11:15
pokolimar: and why you cant do it in create/write?11:16
marbecause I have InvoiceLine(quantity=13, line_moves=[move1, move2]11:16
marmove1, move2.quantity == 1311:16
mari change InvoiceLine.quantity = 1211:16
marand I want to update move1.quantity and move2.quantity = 1211:17
marso I need move1 and
mardoes it sound wrong?11:18
marmaybe I'm missing some depends=...?11:19
maryou're suggesting I do this in11:27
marInvoiceLine.write(cls, records, values) ?11:27
pokolimar: yes11:27
pokolimar: and also for create11:28
marI just need it for update11:30
marit's complicated, because write takes many records :/11:31
pokolimar: you simply need a loop on each record and make calcs inside the loop11:32
pokolicedk: ping11:33
marwhat if I need to throw validation error?11:33
marand what if I need to write different values on different records?11:33
marsplit writes?11:34
pokolimar: first question: better to use check11:34
pokolimar: second question just call super() when you need11:34
-!- lfm_( has joined #tryton11:34
marso I get write([record1, record2], {quantity: 12.00})11:35
marand now I ant to write11:35
marrecord1: line_moves[0].quantity = 1211:35
marrecord2[1].quantity = 1311:35
marso I to .write([record1], record1_values) and .write([record2], record2_values)?11:36
mar*so I do11:36
pokolimar: but you need to write on InvoiceLine or on line_move?11:36
maron InvoiceLine11:37
maron LineMove11:37
mari don't need to change InvoiceLine, just throw validation error if I can't write it on LineMove11:37
pokolimar: so Just get the model from the pool and perform any writes you need11:40
-!- vernichon( has joined #tryton11:40
marin write method?11:48
-!- rpit( has joined #tryton11:48
cedkpokoli: pong11:49
pokolicedk: can I push to And if I push there is something I need to do to update the website?11:51
pokolimar: yes11:51
cedkpokoli: no you can't11:52
pokolicedk: so I send you the patches by email?11:53
cedkpokoli: yes11:54
pokolicedk: ok, thanks :)11:55
marpokoli, what about validation? can I throw user error in write()?11:56
pokolimar: better to use validate
marbut I need to do this validation only when changing quantity11:59
marI probably won't know if that's the case in validate?12:00
cedkmar: validation on changing event is wrong, validation is about data integrity12:04
-!- pobsteta(~Thunderbi@ has joined #tryton12:07
-!- lfm_( has joined #tryton13:12
-!- asoleh(~asoleh@ has joined #tryton13:40
-!- jeancavallo( has joined #tryton14:01
-!- refnode( has joined #tryton14:46
-!- marius_( has joined #tryton14:53
-!- marius_( has joined #tryton15:48
-!- marius_( has joined #tryton15:55
-!- mariomop(~quassel@ has joined #tryton16:09
-!- pobsteta(~Thunderbi@ has joined #tryton16:10
-!- alisonken1lap3( has joined #tryton16:25
-!- marius_( has joined #tryton16:37
-!- digitalsatori(~Thunderbi@ has joined #tryton17:02
-!- Telesight( has joined #tryton18:33
-!- gremly(~gremly@ has joined #tryton19:03
-!- Telesight1( has joined #tryton19:09
-!- Telesight( has joined #tryton19:52
-!- marius_(~marius@ has joined #tryton21:14

Generated by 2.11.0 by Marius Gedminas - find it at!