CREATE OR REPLACE VIEW rv_pp_order AS 
SELECT 
o.ad_client_id,
o.ad_org_id,
o.isactive,
o.created,
o.createdby,
o.updated,
o.updatedby,
o.pp_order_id,
o.documentno,
o.docstatus,
o.m_warehouse_id,
o.m_product_id,
o.qtyentered,
o.qtyreject,
o.qtyscrap,
o.qtybatchs,
o.qtybatchsize,
o.dateordered,
o.datepromised,
o.datestart,
o.datestartschedule,
o.datefinish,
o.datefinishschedule,
o.dateconfirm,
o.datedelivered,
o.lot,
o.pp_product_bom_id,
o.ad_workflow_id,
( SELECT p.weight FROM m_product p WHERE p.m_product_id = o.m_product_id) AS weight,
o.c_doctypetarget_id,
o.m_attributesetinstance_id,
o.planner_id,
o.priorityrule,
o.ad_orgtrx_id,
o.user1_id,
o.user2_id,
o.c_doctype_id,
o.line,
o.description,
o.s_resource_id,
o.floatbefored,
o.floatafter,
o.c_uom_id,
o.qtyordered,
o.qtydelivered,
o.yield,
o.c_project_id,
o.c_campaign_id,
o.c_activity_id,
o.isapproved,
o.isprinted,
o.isselected, 
o.processed, 
o.assay, 
o.isqtypercentage, 
o.ordertype, 
o.issotrx, 
o.scheduletype, 
o.serno
FROM pp_order o;