-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[ADD] custom_picking_delivery_note_report: module to add MO delivery … #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c0a1aea
[ADD] custom_picking_delivery_note_report: module to add MO delivery …
ksar-odoo 71721bd
[ADD] Sell product as kit: added module to sell the product as a kit
ksar-odoo 105421b
[IMP] sell_product_kit: report creation print order done
ksar-odoo 2528c3a
[IMP] sell_product_kit: report and preview update in quatation order
ksar-odoo 1d523aa
[IMP] sell_product_kit: restricted user to create prod and fixed a bug
ksar-odoo 5435258
[MOV] sell_product_kit: Sell multiple product as a kit
ksar-odoo 3c1febf
[IMP] sell_product_kit: Sell multiple product as a kit
ksar-odoo 55f652c
[IMP] sell_product_kit: Sell multiple product as a kit
ksar-odoo 67e7147
[IMP] custom_picking_delivery_note_report: mrp dependency added
ksar-odoo f2884ef
[IMP] sell_product_kit: suggested changes fix
ksar-odoo 21ff236
[IMP] sell_product_kit: code standard commit fix
ksar-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
'name': 'MO delivery note(Inventory)', | ||
'description': "Module used to add MO delivery note report in stock(inventory) module", | ||
'installable': True, | ||
'application': False, | ||
'depends': ['stock', 'mrp'], | ||
'data': [ | ||
'report/mo_report_deliveryslip_template.xml', | ||
'report/custom_picking_delivery_note_report.xml', | ||
], | ||
'license':'LGPL-3' | ||
} |
14 changes: 14 additions & 0 deletions
14
custom_picking_delivery_note_report/report/custom_picking_delivery_note_report.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="action_report_custom_picking_delivery_note" model="ir.actions.report"> | ||
<field name="name">MO Delivery Note</field> | ||
<field name="model">stock.picking</field> | ||
<field name="report_type">qweb-pdf</field> | ||
|
||
<field name="report_name">custom_picking_delivery_note_report.mo_report_deliveryslip_template</field> | ||
|
||
<field name="print_report_name">'MO Delivery Note - %s - %s' % (object.partner_id.name or '', object.name)</field> | ||
<field name="binding_model_id" ref="stock.model_stock_picking"/> | ||
<field name="binding_type">report</field> | ||
</record> | ||
</odoo> |
43 changes: 43 additions & 0 deletions
43
custom_picking_delivery_note_report/report/mo_report_deliveryslip_template.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<template id="mo_report_deliveryslip_template"> | ||
<t t-foreach="docs" t-as="o"> | ||
<t t-call="custom_picking_delivery_note_report.report_delivery_document" t-lang="o._get_report_lang()"/> | ||
</t> | ||
</template> | ||
|
||
<template id="report_delivery_document" inherit_id="stock.report_delivery_document" primary="True"> | ||
<xpath expr="//table[@name='stock_move_table']/tbody" position="replace"> | ||
<tbody> | ||
<t t-set="lines" t-value="o.move_ids.filtered(lambda x: x.product_uom_qty)"/> | ||
|
||
<tr t-foreach="lines" t-as="move"> | ||
<t t-if="move.bom_line_id.bom_id.type != 'phantom'"> <!-- !condition to not print KITS for MO Delivery note --> | ||
<td> | ||
<span t-field="move.product_id">Customizable Desk</span> | ||
<p t-if="move.description_picking and move.description_picking != move.product_id.name and move.description_picking != move.product_id.display_name"> | ||
<span t-field="move.description_picking">Description on transfer</span> | ||
</p> | ||
</td> | ||
<td class="text-end"> | ||
<span t-field="move.product_uom_qty">3.00</span> | ||
<span t-field="move.product_uom" groups="uom.group_uom">units</span> | ||
<span t-if="move.product_packaging_id"> | ||
(<span t-field="move.product_packaging_qty" t-options='{"widget": "integer"}'/> <span t-field="move.product_packaging_id"/>) | ||
</span> | ||
</td> | ||
<td class="text-end"> | ||
<span t-field="move.quantity">3.00</span> | ||
<span t-field="move.product_uom" groups="uom.group_uom">units</span> | ||
<span t-if="move.product_packaging_id"> | ||
(<span t-field="move.product_packaging_quantity" t-options='{"widget": "integer"}'/> <span t-field="move.product_packaging_id"/>) | ||
</span> | ||
</td> | ||
</t> | ||
</tr> | ||
</tbody> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import wizard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
'name': 'Sell Product Kit', | ||
'description': "Module to add function to sell product as a kit.", | ||
'installable': True, | ||
'application': False, | ||
'depends': ['product', 'sale', 'sale_management'], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'views/product_template_form_view_inherited.xml', | ||
'wizard/product_kit_view_wizard.xml', | ||
'views/view_order_form_inherited.xml', | ||
'report/sale_order_document_report.xml', | ||
'report/sale_portal_templates_report.xml' | ||
], | ||
'license':'LGPL-3' | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import product_template | ||
from . import sale_order_line | ||
from . import sale_order |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
is_kit = fields.Boolean(string="Is Kit", default=False) | ||
sub_products_ids = fields.Many2many(comodel_name="product.product", string="Sub Products") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from odoo import models, fields | ||
|
||
class SaleOrder(models.Model): | ||
_inherit='sale.order' | ||
|
||
print_in_report=fields.Boolean(string="Print in report?") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from odoo import fields, models, api | ||
|
||
class SaleOrderLine(models.Model): | ||
_inherit= "sale.order.line" | ||
|
||
is_kit_product = fields.Boolean( | ||
string="Is the product is a kit?", | ||
related='product_template_id.is_kit', | ||
depends=['product_id'] | ||
) | ||
|
||
prev_filled_unit_price=fields.Float() | ||
|
||
product_kit_line_id = fields.Many2one( | ||
string="Linked product kit Line", | ||
comodel_name='sale.order.line', | ||
ondelete='cascade', | ||
domain="[('order_id', '=', order_id)]", | ||
copy=False, | ||
index=True, | ||
) | ||
linked_product_kit_ids = fields.One2many( | ||
string="Linked product kit Lines", comodel_name='sale.order.line', inverse_name='product_kit_line_id', | ||
) | ||
|
||
is_sub_line= fields.Boolean( | ||
default=False, | ||
compute="_compute_is_sub_line", | ||
store=True | ||
ksar-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
@api.depends('product_kit_line_id') | ||
def _compute_is_sub_line(self): | ||
for record in self: | ||
if(record.product_kit_line_id): | ||
record.is_sub_line= True | ||
|
||
def action_open_add_kit_wizard(self): | ||
return { | ||
'type' : 'ir.actions.act_window', | ||
'name' : f'Product: {self.product_id.name}', | ||
'res_model' : 'product.kit', | ||
'view_type' : 'form', | ||
'view_mode' : 'form', | ||
'target' : 'new', | ||
'context': { | ||
'product_template_id': self.product_template_id.id, | ||
'sale_order_line_id': self.id | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<!--report to show sublines while clicking on setting>print/Quatation-order button in QO--> | ||
<template id="sale_order_document_report_inherited" inherit_id="sale.report_saleorder_document"> | ||
<xpath expr="//tbody/t/tr" position="attributes"> | ||
<attribute name="t-if">(doc.print_in_report) or (not line.is_sub_line)</attribute> | ||
<!-- do not show kit product kit sub lines--> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<!--report whether to show sublines while clicking on preview button in QO--> | ||
<template id="sale_portal_templates_report_inherited" inherit_id="sale.sale_order_portal_content"> | ||
<xpath expr="//table[@id='sales_order_table']/tbody/t/tr" position="attributes"> | ||
<attribute name="t-if">(sale_order.print_in_report) or (not line.is_sub_line)</attribute> | ||
<!-- do not show kit product kit sub lines--> | ||
</xpath> | ||
</template> | ||
|
||
</odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_product_kit,access_product_kit,model_product_kit,base.group_user,1,1,1,1 | ||
access_product_kit_lines,access_product_kit_lines,model_product_kit_lines,base.group_user,1,1,1,1 |
17 changes: 17 additions & 0 deletions
17
sell_product_kit/views/product_template_form_view_inherited.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="product_template_form_view_inherited" model="ir.ui.view"> | ||
<field name="name">inherited.product.kit.view.form</field> | ||
<field name="model">product.template</field> | ||
<field name="inherit_id" ref="product.product_template_form_view"/> | ||
|
||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='group_general']" position="inside"> | ||
<field name="is_kit"/> | ||
<field name="sub_products_ids" widget="many2many_tags" invisible="not is_kit"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
|
||
<record id="view_order_form_inherited" model="ir.ui.view"> | ||
<field name="name">inherited.sale.order.view.form</field> | ||
<field name="model">sale.order</field> | ||
<field name="inherit_id" ref="sale.view_order_form"/> | ||
|
||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='product_template_id']" position="after"> | ||
<button name="action_open_add_kit_wizard" type="object" class="btn-secondary" string="Add/Update Kit" invisible="not is_kit_product or state in ('sale')"/> | ||
</xpath> | ||
|
||
<xpath expr="//field[@name='order_line']/list" position="attributes"> | ||
<attribute name="decoration-muted">is_sub_line</attribute> | ||
</xpath> | ||
|
||
<xpath expr="//field[@name='payment_term_id']" position="after"> | ||
<field name="print_in_report"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_kit_model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from odoo import models, fields, api | ||
|
||
class ProductKit(models.TransientModel): | ||
_name="product.kit" | ||
|
||
product_kit_line_ids= fields.One2many(comodel_name='product.kit.lines', inverse_name="product_kit_id") | ||
|
||
@api.model | ||
def default_get(self, fields_list): | ||
product_template= self.env['product.template'].browse(self.env.context.get('product_template_id')) | ||
sale_order_line_id = self.env['sale.order.line'].browse(self.env.context.get('sale_order_line_id')) | ||
|
||
defaults = super().default_get(fields_list) | ||
product_kit_line_ids={} | ||
|
||
#Handling subproduct added later case in future case for that Taking union of existing and not existing line() | ||
for c_pro in sale_order_line_id.linked_product_kit_ids: | ||
product_kit_line_ids[c_pro.product_id.id]= { | ||
'product_id':c_pro.product_id.id, | ||
'quantity': c_pro.product_uom_qty, | ||
'price': c_pro.prev_filled_unit_price | ||
} | ||
# is_kit_line_exits[c_pro.product_id.id]=True | ||
for c_pro in product_template.sub_products_ids: | ||
if(c_pro.id not in product_kit_line_ids.keys()): | ||
product_kit_line_ids[c_pro.id]= { | ||
'product_id': c_pro.id, | ||
'quantity': 1, | ||
'price': 0 | ||
} | ||
|
||
defaults['product_kit_line_ids'] = self.env['product.kit.lines'].create(list(product_kit_line_ids.values())) | ||
return defaults | ||
|
||
#adding Sale kit product into sale order line | ||
def action_add_kit_values_to_product(self): | ||
sale_order_line= self.env['sale.order.line'].search([('id','=',self.env.context.get('active_id'))]) | ||
|
||
sub_product_total= 0 | ||
|
||
#is no sale.order.line exist related to the current product order line only then create else update | ||
if(len(sale_order_line.linked_product_kit_ids)==0): | ||
for prod in self.product_kit_line_ids: | ||
self.env['sale.order.line'].create({ | ||
'product_kit_line_id': sale_order_line.id, | ||
'order_id': sale_order_line.order_id.id, | ||
'product_id': prod.product_id.id, | ||
'product_uom_qty': prod.quantity, | ||
'price_unit': 0, | ||
'customer_lead':0, | ||
'prev_filled_unit_price': prod.price | ||
}) | ||
sub_product_total+= prod.quantity * prod.price | ||
|
||
sale_order_line.update({ | ||
'price_subtotal': sale_order_line.price_subtotal+sub_product_total | ||
}) | ||
else: | ||
new_subtotal= sale_order_line.price_subtotal | ||
#remove the old price and add new price; | ||
# formula==> new_subtotal = new_subtotal - (old_qty*price_pu) + (new_qty*price_pu) | ||
# to update the linked_kit_lines details for next time | ||
|
||
old_price=0 | ||
for old_line in sale_order_line.linked_product_kit_ids: | ||
old_price+= old_line.product_uom_qty * old_line.prev_filled_unit_price | ||
|
||
incomming_price=0 | ||
for new_line in self.product_kit_line_ids: | ||
incomming_price+= new_line.quantity * new_line.price | ||
|
||
new_subtotal= new_subtotal - old_price + incomming_price | ||
|
||
for old_line in sale_order_line.linked_product_kit_ids: | ||
for new_line in self.product_kit_line_ids: | ||
if(old_line.product_id.id == new_line.product_id.id): | ||
old_line.update({ | ||
'prev_filled_unit_price': new_line.price, | ||
'product_uom_qty': new_line.quantity, | ||
'price_unit':0 | ||
}) | ||
|
||
sale_order_line.update({ | ||
'price_subtotal': new_subtotal | ||
}) | ||
|
||
self.product_kit_line_ids.unlink() | ||
return True | ||
|
||
class ProductKitLines(models.TransientModel): | ||
_name="product.kit.lines" | ||
|
||
product_kit_id= fields.Many2one(comodel_name="product.kit") | ||
product_id= fields.Many2one(string="product", comodel_name='product.product') | ||
quantity= fields.Float(string="quantity") | ||
price= fields.Float(string="price") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="product_kit_view_form" model="ir.ui.view"> | ||
<field name="name">product kit Form View</field> | ||
<field name="model">product.kit</field> | ||
<field name="arch" type="xml"> | ||
<form string="form_view"> | ||
<h4>SUB PRODUCTS</h4> | ||
<field name="product_kit_line_ids" > | ||
<list create="0" delete="0" editable="bottom"> | ||
<field name="product_id" readonly="1"></field> | ||
<field name="quantity"></field> | ||
<field name="price"></field> | ||
</list> | ||
</field> | ||
<footer> | ||
<button name="action_add_kit_values_to_product" string="Confirm" class='btn btn-primary' type="object"/> | ||
<button special="cancel" string="Cancel"/> | ||
</footer> | ||
</form> | ||
|
||
</field> | ||
|
||
</record> | ||
|
||
</odoo> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.