Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1from odoo import models
2
3
4class StockValuationReport(models.AbstractModel):
5 _inherit = 'stock_account.stock.valuation.report'
6
7 def _get_report_data(self, date=False, product_category=False, warehouse=False):
8 data = super()._get_report_data(date, product_category, warehouse)
9 not_invoiced_received_data = self._compute_goods_received_not_invoiced(date, product_category)
10 data['not_invoiced_received_goods'] = not_invoiced_received_data
11 return data
12
13 def _compute_goods_received_not_invoiced(self, date=False, product_category=False):
14 """ Compute valuation for already received but not invoiced yet goods,
15 purchase order by purchase order."""
16 domain = [('qty_to_invoice', '!=', 0)]
17 if product_category:
18 domain += [('product_id.categ_id', '=', product_category.id)]
19 if date:
20 domain += [('date_approve', '<=', date)]
21 purchase_order_lines = self.env['purchase.order.line'].search(domain)
22 purchase_orders = purchase_order_lines.order_id
23 not_invoiced_received_lines = []
24 total = 0
25 for order in purchase_orders:
26 order_lines = purchase_order_lines.filtered(lambda pol: pol.order_id == order)
27 value = 0
28 for order_line in order_lines:
29 confirmed_invoice_lines = order_line.invoice_lines.filtered(
30 lambda aml: aml.move_id.state == 'posted'
31 )
32 invoiced_value = sum(confirmed_invoice_lines.mapped('amount_currency'), 0)
…lines 33–44 unchanged (12 lines)

After

1from odoo import models
2
3
4class StockValuationReport(models.AbstractModel):
5 _inherit = 'stock_account.stock.valuation.report'
6
7 # TODO remove in master
8 def _compute_goods_received_not_invoiced(self, date=False, product_category=False):
9 """ Compute valuation for already received but not invoiced yet goods,
10 purchase order by purchase order."""
11 domain = [('qty_to_invoice', '!=', 0)]
12 if product_category:
13 domain += [('product_id.categ_id', '=', product_category.id)]
14 if date:
15 domain += [('date_approve', '<=', date)]
16 pol_by_order = self.env['purchase.order.line']._read_group(
17 domain=domain,
18 groupby=['order_id'],
19 aggregates=['id:recordset']
20 )
21 not_invoiced_received_lines = []
22 total = 0
23 for order, order_lines in pol_by_order:
24 value = 0
25 for order_line in order_lines:
26 confirmed_invoice_lines = order_line.invoice_lines.filtered(
27 lambda aml: aml.move_id.state == 'posted'
28 )
29 invoiced_value = sum(confirmed_invoice_lines.mapped('amount_currency'), 0)
…lines 30–41 unchanged (12 lines)

Before

module
import_from_statement
from "from"
dotted_name
identifier "odoo"
import "import"
dotted_name
identifier "models"
class_definition
class "class"
identifier "StockValuationReport"
argument_list
( "("
attribute
identifier "models"
. "."
identifier "AbstractModel"
) ")"
: ":"
block
expression_statement
assignment
identifier "_inherit"
= "="
string
string_start "'"
string_content "stock_account.stock.valuation.report"
string_end "'"
function_definition
def "def"
identifier "_get_report_data"
parameters
( "("
identifier "self"
, ","
default_parameter
identifier "date"
= "="
false "False"
, ","
default_parameter
identifier "product_category"
= "="
false "False"
, ","
default_parameter
identifier "warehouse"
= "="
false "False"
) ")"
: ":"
block
expression_statement
assignment
identifier "data"
= "="
call
attribute
call
identifier "super"
argument_list
( "("
) ")"
. "."
identifier "_get_report_data"
argument_list
( "("
identifier "date"
, ","
identifier "product_category"
, ","
identifier "warehouse"
) ")"
expression_statement
assignment
identifier "not_invoiced_received_data"
= "="
call
attribute
identifier "self"
. "."
identifier "_compute_goods_received_not_invoiced"
argument_list
( "("
identifier "date"
, ","
identifier "product_category"
) ")"
expression_statement
assignment
subscript
identifier "data"
[ "["
string
string_start "'"
string_content "not_invoiced_received_goods"
string_end "'"
] "]"
= "="
identifier "not_invoiced_received_data"
return_statement
return "return"
identifier "data"
function_definition
def "def"
identifier "_compute_goods_received_not_invoiced"
parameters
( "("
identifier "self"
, ","
default_parameter
identifier "date"
= "="
false "False"
, ","
default_parameter
identifier "product_category"
= "="
false "False"
) ")"
: ":"
block
expression_statement
string
string_start "\"\"\""
string_content " Compute valuation for already received but not invoiced yet"...
string_end "\"\"\""
expression_statement (+21 nodes collapsed)
if_statement (+29 nodes collapsed)
if_statement (+26 nodes collapsed)
expression_statement
assignment
identifier "purchase_order_lines"
= "="
call
attribute
subscript
attribute
identifier "self"
. "."
identifier "env"
[ "["
string
string_start "'"
string_content "purchase.order.line"
string_end "'"
] "]"
. "."
identifier "search"
argument_list
( "("
identifier "domain"
) ")"
expression_statement
assignment
identifier "purchase_orders"
= "="
attribute
identifier "purchase_order_lines"
. "."
identifier "order_id"
expression_statement
assignment
identifier "not_invoiced_received_lines"
= "="
list
[ "["
] "]"
expression_statement
assignment
identifier "total"
= "="
integer "0"
for_statement
for "for"
identifier "order"
in "in"
identifier "purchase_orders"
: ":"
block
expression_statement
assignment
identifier "order_lines"
= "="
call
attribute
identifier "purchase_order_lines"
. "."
identifier "filtered"
argument_list
( "("
lambda
lambda "lambda"
lambda_parameters
identifier "pol"
: ":"
comparison_operator
attribute
identifier "pol"
. "."
identifier "order_id"
== "=="
identifier "order"
) ")"
expression_statement
assignment
identifier "value"
= "="
integer "0"
for_statement (+74 nodes collapsed)
expression_statement (+44 nodes collapsed)
expression_statement
augmented_assignment
identifier "total"
-= "-="
identifier "value"
return_statement (+21 nodes collapsed)

After

module
import_from_statement
from "from"
dotted_name
identifier "odoo"
import "import"
dotted_name
identifier "models"
class_definition
class "class"
identifier "StockValuationReport"
argument_list
( "("
attribute
identifier "models"
. "."
identifier "AbstractModel"
) ")"
: ":"
block
expression_statement
assignment
identifier "_inherit"
= "="
string
string_start "'"
string_content "stock_account.stock.valuation.report"
string_end "'"
comment "# TODO remove in master"
function_definition
def "def"
identifier "_compute_goods_received_not_invoiced"
parameters
( "("
identifier "self"
, ","
default_parameter
identifier "date"
= "="
false "False"
, ","
default_parameter
identifier "product_category"
= "="
false "False"
) ")"
: ":"
block
expression_statement
string
string_start "\"\"\""
string_content " Compute valuation for already received but not invoiced yet"...
string_end "\"\"\""
expression_statement (+21 nodes collapsed)
if_statement (+29 nodes collapsed)
if_statement (+26 nodes collapsed)
expression_statement
assignment
identifier "pol_by_order"
= "="
call
attribute
subscript
attribute
identifier "self"
. "."
identifier "env"
[ "["
string
string_start "'"
string_content "purchase.order.line"
string_end "'"
] "]"
. "."
identifier "_read_group"
argument_list
( "("
keyword_argument
identifier "domain"
= "="
identifier "domain"
, ","
keyword_argument
identifier "groupby"
= "="
list
[ "["
string
string_start "'"
string_content "order_id"
string_end "'"
] "]"
, ","
keyword_argument
identifier "aggregates"
= "="
list
[ "["
string
string_start "'"
string_content "id:recordset"
string_end "'"
] "]"
) ")"
expression_statement
assignment
identifier "not_invoiced_received_lines"
= "="
list
[ "["
] "]"
expression_statement
assignment
identifier "total"
= "="
integer "0"
for_statement
for "for"
pattern_list
identifier "order"
, ","
identifier "order_lines"
in "in"
identifier "pol_by_order"
: ":"
block
expression_statement
assignment
identifier "value"
= "="
integer "0"
for_statement (+74 nodes collapsed)
expression_statement (+44 nodes collapsed)
expression_statement
augmented_assignment
identifier "total"
-= "-="
identifier "value"
return_statement (+21 nodes collapsed)