Skip to Content
Menu
This question has been flagged
2419 Views

Hi,

When creating a new customer_invoice I want to add a new journal entries

for that I had add it a new action in the invoice workflow but I'm getting an error could you help me to fix it please.

This is my workflow:

<record id="account.act_open" model="workflow.activity">

<field name="wkf_id" ref="account.wkf" />

<field name="name">done</field>

<field name="name">open</field>

<field name="action">action_date_assign()

action_move_create()

action_move_create_two()

action_number()

invoice_validate()

</field>

<field name="kind">function</field>

</record>

This is my python file:

class customer_invoice(osv.osv):

_inherit= 'account.invoice'

_columns={

'product_cost_account':fields.many2one('account.account','Product Cost Account', required= True),

'cost_account':fields.many2one('account.account','Cost Account', required= True),

}

@api.multi

def action_move_create_two(self):

move_obj = self.pool.get('account.move')

for inv in self.browse():

res = {}

res1 = {}

if inv.type == 'out_invoice':

for lines in inv.invoice_line:

cost_price = lines.product_id.standard_price * lines.quantity

print'cost_price',cost_price

res.update({'name':inv.product_cost_account.name, 'debit':cost_price })

res1.update({'name':inv.cost_account.name, 'credit':cost_price })

for i in [res,res1]:

new_move_id = move_obj.create({'line_id': [(0,0, i)]})

self.write({'account_move_id': new_move_id})

Avatar
Discard

You could post your error log

Author

My pb is that I got nothing nothing happened like I did not change it