コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3918 ビュー

Is there anyway by which i can inherit a custom field or column into forecasted report of a product(locations->products-> choose any product -> forecasted 

is there any backend coding tutorial or anything that can help me achieve this goal 


thank you 

アバター
破棄
最善の回答

Hi,

Old question, but figured I'd give an answer still.

I've done this by first inheriting the _prepare_report_line() function from report.stock.report_product_product_replenishment (AbstractModel). You can do this like:

def _prepare_report_line(self, quantity, move_out=None, move_in=None, replenishment_filled=True, product=False, reservation=False):
res = super(ReplenishmentReportInherit, self)._prepare_report_line(quantity, move_out, move_in,
replenishment_filled, product,       reservation)

Then, you can add the necessary data into the "res" variable and return the "res", like:

res['SOME_NAME'] = 'YOUR VARIABLE DATA'

When you've done this, you'll have to inherit the forecast-report template in an XML file, and insert your variable into the table header and body


template id="report_stock_forecasted_inh_shipped" inherit_id="stock.report_product_product_replenishment">
xpath expr="//table[@class='o_report_replenishment table table-bordered']/thead/tr/td[3]" position="after">
td>SOME NAME
/xpath>
xpath expr="//table[@class='o_report_replenishment table table-bordered']/tbody/tr[2]/td[3]" position="after">
td t-esc="line['SOME_NAME'] or ''"/>
/xpath>


Hope this helps!

アバター
破棄
関連投稿 返信 ビュー 活動
1
6月 22
2819
1
5月 22
4634
0
2月 22
3842
0
9月 21
2980
2
8月 24
1580