Add supplier code to purchase order line - odoo

How can i add a the field suppliercode to my purchase.order.line model in odoo
GUI
In the report i was able to do it with
<span t-field="line.product_id.seller_ids and line.product_id.seller_ids[0].product_code"/>
(not my solution, found it on stackoverflow)
Do I use it like in the picture or in server actions

You should create simple compute field in purchase order line.
#api.multi
def get_supplier_code(self):
product_supplier_info_obj=self.env['product.supplierinfo']
for line in self:
purchase_order=line.order_id
supplier_info=product_supplier_info_obj.search([('product_tmpl_id','=',line.product_id.product_tmpl_id.id),('name','=',purchase_order.partner_id.id)],limit=1)
line.product_code=supplier_info.product_code
product_code=fields.Char(compute="get_supplier_code",store=False,string="purchase Code")
This may help you.

Related

Add delete option in lines as like we are having in shopping cart

I have structure as like we have in shopping cart with products.
Following is detailed information about my structure :
I have created one page in website, in which there is a button to add lines where user will enter details like product and quantity.
But there is not any option to remove line.
So I want to add a option to remove any particular line, for that I will add "Trash" icon so user can click on it and delete that line.
Can anyone please help me to make it done as like cart?
I don't see any code in your question so I can't figure it out your classes or functions name, but you could try something like this:
def btn_delete_line(self):
res = super(YourClassName, self).unlink()
return res

How to modify sale order line when an invoice is created?

I do some modification on sale.order.line I add some fields, one of those fields is a checkbox.
my request is when I want to create an invoice only checked line are invoiced, how can I do this Please?
There is two solution for your problem either override create invoice line function or remove sale_order_line(hide) from sales and make new model which has same fields like sale_order_line add all your field there (product, realize all these fields). Gave functionality so that if checkbox is enabled(realize in your case) that automatically will added in sale order line and which checkbox is disable will remove from sale_order_line (You have to override create, write and unlink function of that model). By this way the lines which is enabled will be added in sale_order_line and everything will be done in odoo way

How to confirm multiple sale order in Odoo 10?

I am new to python but I am willing to learn :)
Basically I need to have a menu for confirming multiple sale order in Odoo 10.
So far I found this How to add entry to 'More' menu or top menu to add action on multiple selections? However I am not sure if it is the same for Odoo 10.
I found this code in sale.py
#api.multi
def action_confirm(self):
for order in self:
order.state = 'sale'
order.confirmation_date = fields.Datetime.now()
if self.env.context.get('send_email'):
self.force_quotation_send()
order.order_line._action_procurement_create()
if self.env['ir.values'].get_default('sale.config.settings', 'auto_done_setting'):
self.action_done()
return True
if the above code is can be used for confirming multiple sale orders then all I need is to have extra menu which uses it.
Any pointers on this would be greatly appreciated.
This module may help you https://www.odoo.com/apps/modules/10.0/sale_order_mass_confirm/
It is available in odoo apps.

add input field on bo order table in prestashop

i am new to prestashop
i am trying to add new input field for update weight of order
can anyone help me to know how to add input field in Back Office order tableenter image description here
i myself add that field.
by overriding
helper/list/list_content.tpl
and
helper/list/list_header.tpl
file
and adding extra column in it
after that make ajax call for updation of dataenter image description here

Can I inherit from a standard report in OpenERP?

I want to make changes to the purchase order report in OpenERP 6.1. Do I have to go in and make changes to the purchase module, or can I create a new module that will inherit the standard report and override some details.
You can't exactly inherit another report and just override some details, but you can replace a standard report and make all existing links to it launch your new report instead.
Our zaber_purchase module contains some changes to the purchase order report that our users wanted. Here's the purchase_report.xml file that replaces the standard report with ours.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
auto="False"
id="purchase.report_purchase_order"
model="purchase.order"
name="purchase.order.zaber"
rml="zaber_purchase/report/order.rml"
string="Purchase Order"
usage="default"/>
</data>
</openerp>
Since it's not inheriting but replacing the report, you have to duplicate the whole report in your version. Your report's id has to match the original report's id, including the module name. In the example above, the original report has an id of report_purchase_order, and it's part of the purchase module, so your report id must be purchase.report_purchase_order to replace it. The name has to match the name in your version's parser file, and the rml attribute has to point to your version's RML file.
Thanks to mihai for explaining most of this in the OpenERP forum.
Don Kirkby has a good answer, and after banging my head on a wall for an hour, I'd like to expand it. But stackoverflow, in all its wisdom, won't let me comment on it because I don't have enough rep points, so instead, I'll spam the question with an unanswer.
By "The id has to match the original report's id, including the module name," Don means that if foomodule has <report id="fooreport" ...>, then in your module you will need to say <report id="foomodule.fooreport" ...>. This is because the ids declared by each module live in a namespace scoped to that module. If you don't reference the other (the one you are overriding) module's namespace, then you just end up creating a new report with the same name which is Bad.
For kicks, check out the database tables ir_act_report_xml, which has all the reports, and ir_model_data, which associates reports (and everything else) with the id attribute from the XML that defined the thing.
RML parser classes are registered globally as Services. For example the Sale Order parser class is registered in addons/sale/report/sale_order.py with
report_sxw.report_sxw('report.sale.order', 'sale.order', 'addons/sale/report/sale_order.rml', parser=order, header="external")
If you try to create another parser with the same name, you get an error : The report "sale.order" already exists!
A simple way to replace the sale.order parser and use a custom parser class is to remove it from the global service registry with :
from netsvc import Service
del Service._services['report.sale.order']
Here is a full example we used to conditionally hide the Discount column in the sale order report if there is no discount
from sale.report import sale_order
from report import report_sxw
# create a custom parser inherited from sale order parser:
class new_order_parser(sale_order.order):
'''Custom parser with an additional method
'''
def __init__(self, cr, uid, name, context):
super(new_order_parser, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'has_line_discount': self._has_line_discount,
})
def _has_line_discount(self, order):
return any([l.discount for l in order.order_line])
# remove previous sale.report service :
from netsvc import Service
del Service._services['report.sale.order']
# register the new report service :
report_sxw.report_sxw(
'report.sale.order',
'sale.order',
'addons/path/to/the/sale_order.rml',
parser=new_order_parser
)