mirror of
https://github.com/bringout/oca-workflow-process.git
synced 2026-04-20 18:12:01 +02:00
Initial commit: OCA Workflow Process packages (456 packages)
This commit is contained in:
commit
d366e42934
18799 changed files with 1284507 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
from . import purchase_order
|
||||
from . import product_product
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
# © 2014 Today Akretion
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# @author Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
|
||||
# @author Pierrick Brun <pierrick.brun@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = "product.product"
|
||||
|
||||
# for searching purpose
|
||||
variant_specific_seller_ids = fields.One2many("product.supplierinfo", "product_id")
|
||||
po_line_ids = fields.One2many(
|
||||
comodel_name="purchase.order.line",
|
||||
inverse_name="product_id",
|
||||
help="Technical: used to compute quantities to purchase.",
|
||||
)
|
||||
seller_price = fields.Float(compute="_compute_seller_price")
|
||||
|
||||
def _compute_seller_price(self):
|
||||
po = self.pma_parent
|
||||
for record in self:
|
||||
seller = record._select_seller(
|
||||
partner_id=po.partner_id,
|
||||
quantity=record.qty_to_process or 1,
|
||||
uom_id=record.quick_uom_id,
|
||||
)
|
||||
price_unit = record.uom_id._compute_price(
|
||||
seller.price,
|
||||
record.quick_uom_id,
|
||||
)
|
||||
if self.pma_parent.currency_id != seller.currency_id:
|
||||
price_unit = seller.currency_id._convert(
|
||||
price_unit, po.currency_id, po.company_id, po.date_order.date()
|
||||
)
|
||||
record.seller_price = price_unit
|
||||
|
||||
def _default_quick_uom_id(self):
|
||||
if self.env.context.get("parent_model", False) == "purchase.order":
|
||||
return self.uom_po_id
|
||||
return super()._default_quick_uom_id()
|
||||
|
||||
def _compute_process_qty_purchase(self):
|
||||
po_lines = self.env["purchase.order.line"].search(
|
||||
[("order_id", "=", self.env.context.get("parent_id"))]
|
||||
)
|
||||
for product in self:
|
||||
product.qty_to_process = sum(
|
||||
po_lines.filtered(lambda l: l.product_id == product).mapped(
|
||||
"product_qty"
|
||||
)
|
||||
)
|
||||
|
||||
@api.depends("po_line_ids")
|
||||
def _compute_process_qty(self):
|
||||
res = super()._compute_process_qty()
|
||||
if self.env.context.get("parent_model", False) == "purchase.order":
|
||||
self._compute_process_qty_purchase()
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
purchase = self.env["purchase.order"].browse(self.env.context.get("parent_id"))
|
||||
if self.env.context.get("in_current_parent") and purchase:
|
||||
po_lines = self.env["purchase.order.line"].search(
|
||||
[("order_id", "=", purchase.id)]
|
||||
)
|
||||
args.append(("id", "in", po_lines.mapped("product_id").ids))
|
||||
if self.env.context.get("for_current_supplier") and purchase:
|
||||
seller = purchase.partner_id
|
||||
seller = seller.commercial_partner_id or seller
|
||||
args += [
|
||||
"|",
|
||||
("variant_specific_seller_ids.partner_id", "=", seller.id),
|
||||
"&",
|
||||
("seller_ids.partner_id", "=", seller.id),
|
||||
("product_variant_ids", "!=", False),
|
||||
]
|
||||
return super().search(
|
||||
args, offset=offset, limit=limit, order=order, count=count
|
||||
)
|
||||
|
||||
@api.model
|
||||
def check_access_rights(self, operation, raise_exception=True):
|
||||
"""hijack product edition rights if we're in the mass edition menu"""
|
||||
if self.env.context.get("quick_access_rights_purchase"):
|
||||
return self.env["purchase.order.line"].check_access_rights(
|
||||
operation, raise_exception
|
||||
)
|
||||
return super().check_access_rights(operation, raise_exception)
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
# © 2014 Today Akretion
|
||||
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||
# @author Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
|
||||
# @author Pierrick Brun <pierrick.brun@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from odoo import _, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class PurchaseOrder(models.Model):
|
||||
_name = "purchase.order"
|
||||
_inherit = ["purchase.order", "product.mass.addition"]
|
||||
|
||||
def add_product(self):
|
||||
self.ensure_one()
|
||||
res = self._common_action_keys()
|
||||
res["context"].update(
|
||||
{
|
||||
"search_default_filter_to_purchase": 1,
|
||||
"search_default_filter_for_current_supplier": 1,
|
||||
"quick_access_rights_purchase": 1,
|
||||
}
|
||||
)
|
||||
commercial = self.partner_id.commercial_partner_id.name
|
||||
res["name"] = "🔙 {} ({})".format(_("Product Variants"), commercial)
|
||||
res["view_id"] = (self.env.ref("purchase_quick.product_tree_view4purchase").id,)
|
||||
res["search_view_id"] = (
|
||||
self.env.ref("purchase_quick.product_search_form_view").id,
|
||||
)
|
||||
return res
|
||||
|
||||
def _get_quick_line(self, product):
|
||||
result = self.env["purchase.order.line"].search(
|
||||
[("product_id", "=", product.id), ("order_id", "=", self.id)]
|
||||
)
|
||||
nr_lines = len(result.ids)
|
||||
if nr_lines > 1:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"Must have only 1 line per product for mass addition, but "
|
||||
"there are %(nr_lines)s lines for the product %(product_name)s",
|
||||
nr_lines=nr_lines,
|
||||
product_name=product.display_name,
|
||||
)
|
||||
)
|
||||
return result
|
||||
|
||||
def _get_quick_line_qty_vals(self, product):
|
||||
return {
|
||||
"product_id": None,
|
||||
"product_uom": product.quick_uom_id.id,
|
||||
"product_qty": product.qty_to_process,
|
||||
}
|
||||
|
||||
def _complete_quick_line_vals(self, vals, lines_key=""):
|
||||
# This params are need for playing correctly the onchange
|
||||
vals_to_add = {
|
||||
"order_id": self.id,
|
||||
"partner_id": self.partner_id.id,
|
||||
}
|
||||
vals_to_add.update(vals)
|
||||
vals = vals_to_add
|
||||
return super(PurchaseOrder, self)._complete_quick_line_vals(
|
||||
vals, lines_key="order_line"
|
||||
)
|
||||
|
||||
def _add_quick_line(self, product, lines_key=""):
|
||||
return super(PurchaseOrder, self)._add_quick_line(
|
||||
product, lines_key="order_line"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue