Odoo 13 - How to Add New Column in Sales Order Lines tab - odoo-13

How to Add new field in Sales Order lines Tab in Odoo 13?
My Goal is to add new field/column before Product column in Sales Order Line tab.

res_sale_order_line.py
class ResSaleOrderLine(models.Model):
_inherit = "sale.order.line"
new_field = fields.Many2one('product.product', string='New Field')
views.xml
<xpath expr="//page[#name='order_lines']/field[#name='order_line']/form/group/group/field[#name='product_id']" position="before"> <field name="new_field"/> </xpath>
<xpath expr="//page[#name='order_lines']/field[#name='order_line']/tree/field[#name='product_id']" position="before"> <field name="new_field"/> </xpath>

Related

Backoffice : How to filter Date entries based on Year using referenceSearchCondition in Create/Editor Wizard

SAP Commerce 1811
We have a model like this ..
HolidayCalendar has an attribute Year of Integer type and collection of Holiday Calendar Entries.
HolidayCalendarEntry has attribute Date
In Backoffice -> Create/Editor Wizard, i want to apply referenceSearchCondition filter on HolidayCalendar:Entries attribute so that whenever i choose existing entries in Holiday Calendar i can get only those entries fall under associated year.
e.g. I created new Holiday Calendar of 2021, then i can see only those entries which has date of 2021.
So far I tried something with Dynamic Form but its not working
<context type="HolidayCalendar" component="editorAreaDynamicForms" merge-by="module">
<df:dynamicForms xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms">
<df:attribute id="dynamicFormsEntryFiltering1" paramName="referenceSearchCondition_date_greaterOrEquals" disabledIf="date==null" computedValue="T(com.hybris.util.DateUtils).getFirstDay(parentObject.year)" qualifier="entries" triggeredOn="date"/>
</df:dynamicForms>
</context>
<context type="HolidayCalendar" component="editorAreaDynamicForms" merge-by="module">
<df:dynamicForms xmlns:df="http://www.hybris.com/cockpitng/component/dynamicForms">
<df:attribute id="dynamicFormsEntryFiltering2" paramName="referenceSearchCondition_date_lessOrEquals" disabledIf="date==null" computedValue="T(com.hybris.util.DateUtils).getLastDay(parentObject.year)" qualifier="entries" triggeredOn="date"/>
</df:dynamicForms>
</context>
Here I am trying to set a range of FirstDay and LastDay of Holiday Calendar Year and match entries date fall under it. But it's not working.
Any other suggestion how to achieve this ?
You can create a custom editor for "entries" attribute,
public class EntriesEditor<T> extends DefaultMultiReferenceEditor<T>
Override the method and add your filter condition within this method
updateReferencesListBoxModel
Reference this custom editor in your config.xml,
<wz:property qualifier="entries" editor="com.backoffice.editors.entrieseditor" />

NetSuite Saved Search for Kit/Package - How to include columns for each component and their quantity

I am trying to create a Saved Search for Kit/Package records. Each Kit/Package includes two component SKUs. The desired result is to have a Saved Search that pulls in each component SKU into its own column. I would also like another column for each of the respective quantities.
I am using this Saved Search to create an Advanced PDF/HTML template. So, I cannot use a Saved Search that includes summary fields. Also, these items cannot be grouped in the Saved Search because I need to reference them separately in the Advanced PDF/HTML template.
EXAMPLE: Kit/Package SKU "XYZXYZ" includes 10 x "Component 1" and 1 x "Component 2". The Saved Search would include the following columns:
Kit/Package SKU
Component 1 SKU
Component 1 QTY
Component 2 SKU
Component 2 QTY
How can I accomplish my goal?
This can be done. Follow the steps below:
1) Create an Item saved search.
2) Use the following settings
Criteria: Type is Kit/Package
Result: Name
Result: Member Item (Or whatever you're using for SKU. Maybe Member Item Fields...Internal ID)
Result: Member Quantity
Available Filter: Name. Show in Filter : Yes
Save & Run
3) Create the Advanced HTML template. Use this code
<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
</head>
<body>
<table>
<tr>
<td>
<#list results as result>
<#if result_index==0>
Kit/Package SKU ${result.itemid} includes ${result.memberquantity} x ${result.memberitem}</#if>
<#if result_index==1> and ${result.memberquantity} x ${result.memberitem}
</#if>
</#list>
</td>
</tr>
</table>
</body>
</pdf>
This is currently not a feature supported by NetSuite. There is an enhancement request submitted for this feature.

Search query for multiple column with comma separated string

$category_string="244,46,45";
I want query that will return product id only 239.
when i am trying to search by select * from category where category in($category_string) then it will give me all rows.
<table>
<tr><td>category_id</td><td>product_id</td></tr>
<tr><td>244</td><td>239</td></tr>
<tr><td>46</td><td>239</td></tr>
<tr><td>45</td><td>239</td></tr>
<tr><td>45</td><td>240</td></tr>
<tr><td>46</td><td>240</td></tr>
<tr><td>45</td><td>241</td></tr>
<tr><td>46</td><td>241</td></tr>
<tr><td>45</td><td>242</td></tr>
<tr><td>46</td><td>242</td></tr>
</tr>
<table>
If you want only 239
SELECT * FROM category WHERE product_id IN ( 239 );
OR
SELECT * FROM category WHERE product_id = 239;
Since you are comparing for only one product_id, i would suggest 2 query.

Pragmatically Get Count of Pivot Table Data

Suppose I have some sample data like so:
and I create a Pivot Table and order by Product > Sales Rep > Sales
If I want the # of sales John had for Product1 I would do =GETPIVOTDATA("Sales",$A$3,"Product","Product1","Sales Rep","John")
But how would I get a count of the entries there are. i.e. for Product1, John had 4 and Kevin had 2
Is it possible to get this count using GETPIVOTDATA()?
To get this you need to add another Sales field to the values section and change the "Summarize By" to Count. Then the formula will =GETPIVOTDATA("Count of Sales",$A$3,"Product","Product1") will get you the count of Product Overall.

SharePoint 2010 Populate Lookup Field on Activation

I have two lists: [Parents] [Children]. The Children list has a one-to-one lookup column to the Parents list. When deploying the Children List I have data written into the tag using
<Data>
<Rows>
<Row>
<Field Name="ChildName">Stephanie</Field>
<Field Name="ParentNameLookup">What value goes here?</Field>
</Row>
</Rows>
</Data>
My question: is there a way to populate the data into the tag for the ParentNameLookup field?
Try this
<Field Name="ParentNameLookup">ID;#VALUE</Field>
Where ID is ID of the Parent List Item and VALUE Represents actual Text.

Resources