Skip to Content
Menu
This question has been flagged
1 Reply
2425 Views

hi, i am trying to transfer data from a few selected cases in a customized model called 'x_case' at tree view to account.invoice, by using server action.  From sample code, it has created case model and case_line model and transfer the data to invoice model and invoice_line model.  While i tried to avoid the case_line for my own purpose.  however, i've got the attribute error. i've browsed around and cannot find the right solution.   Can you please help? i am new to python and coding. 


ValueError: <class 'AttributeError'>: "'x_case' object has no attribute 'x_case'" while evaluating


case_lines=[] 

for case_line in record.x_case:

  case_lines.append([0,0,{

    'x_studio_case':case_line.x_studio_case_id,

    'x_studio_business_unit': case_line.x_studio_billing_centre,

    'product_id':case_line.x_studio_field_8Cfba.id,

    'name':case_line.x_studio_third_party_name_1,

    'x_studio_billing_details':case_line.x_studio_billing_details,

    'quantity':1,

    'price_unit': case_line.x_studio_price,

    'account_id': record.x_studio_field_8Cfba.property_account_income_id.id

  }]) 

env ['account.invoice'].create({

  'partner_id':record.x_studio_field_hry7Z.id,

  'currency_id':record.x_currency_id.id,

  'invoice_line_ids':case_lines

})


Avatar
Discard
Author Best Answer

i have updated to records and its working now. However, i cannot group the case lines into 1 invoice.  What should i change? 

case_lines=[] 

for case_line in records:

  case_lines.append([0,0,{

    'x_studio_case':case_line.x_studio_case_id,

    'x_studio_business_unit': case_line.x_studio_billing_centre,

    'product_id':case_line.x_studio_field_8Cfba.id,

    'name':case_line.x_studio_third_party_name_1,

    'x_studio_billing_details':case_line.x_studio_billing_details,

    'quantity':1,

    'price_unit': case_line.x_studio_price,

    'account_id': case_line.x_studio_field_8Cfba.property_account_income_id.id

  }]) 

env ['account.invoice'].create({

  'partner_id':records.x_studio_field_hry7Z[0].id,

  'currency_id':records.x_currency_id[0].id,

  'invoice_line_ids':case_lines

})

Avatar
Discard
Related Posts Replies Views Activity
1
Dec 24
181
0
Nov 24
70
2
Jul 24
716
0
Apr 24
564
3
Mar 24
589